Avoid out-of-bounds access by running num_active_touches < 0 (#49439)

If a touch is active during driver init, the slot will be set to
SLOTSTATE_CLOSE when it finishes. That could decrease num_active_touches to
less than 0, causing out-of-bounds access.

X.Org Bug 49439 <http://bugs.freedesktop.org/show_bug.cgi?id=49439>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 77d766b1d5)
This commit is contained in:
Peter Hutterer
2012-05-11 12:27:39 +10:00
parent e0f5688994
commit 23065a974e

View File

@@ -3128,7 +3128,9 @@ UpdateTouchState(InputInfoPtr pInfo, struct SynapticsHwState *hw)
priv->open_slots[j] = priv->open_slots[j + 1];
}
priv->num_active_touches--;
BUG_WARN(priv->num_active_touches == 0);
if (priv->num_active_touches > 0)
priv->num_active_touches--;
}
}