Add agressive event type checking.
Best to FatalError if a wrong event comes in. At least that forces me to fix it really quickly. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
836864b657
commit
6fe4c28bf4
|
@ -891,6 +891,8 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
|
|||
DeviceIntPtr mouse = NULL, kbd = NULL;
|
||||
DeviceEvent *event = (DeviceEvent*)ev;
|
||||
|
||||
CHECKEVENT(ev);
|
||||
|
||||
if (IsPointerDevice(device))
|
||||
{
|
||||
kbd = GetPairedDevice(device);
|
||||
|
|
|
@ -2247,6 +2247,8 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
|
|||
xEvent *xE = NULL;
|
||||
int rc, count = 0;
|
||||
|
||||
CHECKEVENT(event);
|
||||
|
||||
/* XXX: In theory, we could pass the internal events through to everything
|
||||
* and only convert just before hitting the wire. We can't do that yet, so
|
||||
* DDE is the last stop for internal events. From here onwards, we deal
|
||||
|
@ -2527,6 +2529,8 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
|
|||
WindowPtr prevSpriteWin;
|
||||
SpritePtr pSprite = pDev->spriteInfo->sprite;
|
||||
|
||||
CHECKEVENT(ev);
|
||||
|
||||
prevSpriteWin = pSprite->win;
|
||||
|
||||
if (ev && !syncEvents.playingEvents)
|
||||
|
|
|
@ -62,6 +62,10 @@ enum {
|
|||
ET_Internal = 0xFF /* First byte */
|
||||
} EventType;
|
||||
|
||||
#define CHECKEVENT(ev) if (ev && ((InternalEvent*)(ev))->u.any.header != 0xFF) \
|
||||
FatalError("Wrong event type %d.\n", \
|
||||
((InternalEvent*)(ev))->u.any.header);
|
||||
|
||||
/**
|
||||
* Used for ALL input device events internal in the server until
|
||||
* copied into the matching protocol event.
|
||||
|
|
|
@ -162,6 +162,8 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
|
|||
pthread_mutex_lock(&miEventQueueMutex);
|
||||
#endif
|
||||
|
||||
CHECKEVENT(e);
|
||||
|
||||
/* avoid merging events from different devices */
|
||||
if (e->u.any.type == ET_Motion)
|
||||
isMotion = pDev->id;
|
||||
|
@ -285,6 +287,8 @@ static void
|
|||
FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev,
|
||||
InternalEvent* original, InternalEvent *master)
|
||||
{
|
||||
CHECKEVENT(original);
|
||||
CHECKEVENT(master);
|
||||
/* Ensure chained button mappings, i.e. that the detail field is the
|
||||
* value of the mapped button on the SD, not the physical button */
|
||||
if (original->u.any.type == ET_ButtonPress ||
|
||||
|
@ -312,6 +316,8 @@ CopyGetMasterEvent(DeviceIntPtr mdev, DeviceIntPtr sdev,
|
|||
int len = original->u.any.length;
|
||||
InternalEvent *mevent;
|
||||
|
||||
CHECKEVENT(original);
|
||||
|
||||
if (master->evlen < len)
|
||||
SetMinimumEventSize(master, 1, len);
|
||||
|
||||
|
@ -337,6 +343,8 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
|
|||
int x = 0, y = 0;
|
||||
DeviceIntPtr master;
|
||||
|
||||
CHECKEVENT(event);
|
||||
|
||||
/* Custom event handler */
|
||||
handler = miEventQueue.handlers[event->u.any.type];
|
||||
|
||||
|
|
Loading…
Reference in New Issue