Xi: if XISetEventMask fails, return this to the client.

The only failure point can be a BadAlloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-09-02 11:16:15 +10:00
parent 993ca5acbd
commit 377a5f655c
5 changed files with 12 additions and 6 deletions

View File

@ -2128,7 +2128,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
* @param len Number of bytes in mask. * @param len Number of bytes in mask.
* @param mask Event mask in the form of (1 << eventtype) * @param mask Event mask in the form of (1 << eventtype)
*/ */
void int
XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client, XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
unsigned int len, unsigned char* mask) unsigned int len, unsigned char* mask)
{ {
@ -2152,7 +2152,8 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
if (len && !others) if (len && !others)
{ {
AddExtensionClient(win, client, 0, 0); if (AddExtensionClient(win, client, 0, 0) != Success)
return BadAlloc;
others= wOtherInputMasks(win)->inputClients; others= wOtherInputMasks(win)->inputClients;
} }
@ -2163,4 +2164,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
memcpy(others->xi2mask[dev->id], mask, len); memcpy(others->xi2mask[dev->id], mask, len);
RecalculateDeviceDeliverableEvents(win); RecalculateDeviceDeliverableEvents(win);
return Success;
} }

View File

@ -164,7 +164,9 @@ ProcXISelectEvents(ClientPtr client)
dev = &dummy; dev = &dummy;
} else } else
dixLookupDevice(&dev, evmask->deviceid, client, DixUseAccess); dixLookupDevice(&dev, evmask->deviceid, client, DixUseAccess);
XISetEventMask(dev, win, client, evmask->mask_len * 4, (unsigned char*)&evmask[1]); if (XISetEventMask(dev, win, client, evmask->mask_len * 4,
(unsigned char*)&evmask[1]) != Success)
return BadAlloc;
evmask = (xXIEventMask*)(((unsigned char*)evmask) + evmask->mask_len * 4); evmask = (xXIEventMask*)(((unsigned char*)evmask) + evmask->mask_len * 4);
evmask++; evmask++;
} }

View File

@ -305,7 +305,7 @@ extern void
XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master,
DeviceChangedEvent *dce); DeviceChangedEvent *dce);
extern void extern int
XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client, XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
unsigned int len, unsigned char* mask); unsigned int len, unsigned char* mask);

View File

@ -131,7 +131,7 @@ void init_simple(void);
/* Declarations for various overrides in the test files. */ /* Declarations for various overrides in the test files. */
void __wrap_WriteToClient(ClientPtr client, int len, void *data); void __wrap_WriteToClient(ClientPtr client, int len, void *data);
void __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask); int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask);
int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access); int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access); int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
Bool __wrap_AddResource(XID id, RESTYPE type, pointer value); Bool __wrap_AddResource(XID id, RESTYPE type, pointer value);

View File

@ -62,8 +62,9 @@
static unsigned char *data[4096 * 16]; /* the request data buffer */ static unsigned char *data[4096 * 16]; /* the request data buffer */
void __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask) int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask)
{ {
return Success;
} }
/* dixLookupWindow requires a lot of setup not necessary for this test. /* dixLookupWindow requires a lot of setup not necessary for this test.