Skip to content

Commit

Permalink
Xi: if XISetEventMask fails, return this to the client.
Browse files Browse the repository at this point in the history
The only failure point can be a BadAlloc.

Signed-off-by: Peter Hutterer <[email protected]>
  • Loading branch information
whot committed Sep 2, 2009
1 parent 993ca5a commit 377a5f6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Xi/exevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
* @param len Number of bytes in mask.
* @param mask Event mask in the form of (1 << eventtype)
*/
void
int
XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
unsigned int len, unsigned char* mask)
{
Expand All @@ -2152,7 +2152,8 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,

if (len && !others)
{
AddExtensionClient(win, client, 0, 0);
if (AddExtensionClient(win, client, 0, 0) != Success)
return BadAlloc;
others= wOtherInputMasks(win)->inputClients;
}

Expand All @@ -2163,4 +2164,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
memcpy(others->xi2mask[dev->id], mask, len);

RecalculateDeviceDeliverableEvents(win);

return Success;
}
4 changes: 3 additions & 1 deletion Xi/xiselectev.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ ProcXISelectEvents(ClientPtr client)
dev = &dummy;
} else
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++;
}
Expand Down
2 changes: 1 addition & 1 deletion include/exevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ extern void
XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master,
DeviceChangedEvent *dce);

extern void
extern int
XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
unsigned int len, unsigned char* mask);

Expand Down
2 changes: 1 addition & 1 deletion test/xi2/protocol-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void init_simple(void);

/* Declarations for various overrides in the test files. */
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 __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
Bool __wrap_AddResource(XID id, RESTYPE type, pointer value);
Expand Down
3 changes: 2 additions & 1 deletion test/xi2/protocol-xiselectevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@

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.
Expand Down

0 comments on commit 377a5f6

Please sign in to comment.