summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-09-02 11:16:15 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-09-03 08:39:27 +1000
commit377a5f655ca88cd836da24ab42361df9f3ff51a2 (patch)
treebc6001f642d3fedc6230216663872c2ebd6033c2
parent993ca5acbdccef9e43cd6580e7cc22cfda1a2578 (diff)
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>
-rw-r--r--Xi/exevents.c7
-rw-r--r--Xi/xiselectev.c4
-rw-r--r--include/exevents.h2
-rw-r--r--test/xi2/protocol-common.h2
-rw-r--r--test/xi2/protocol-xiselectevents.c3
5 files changed, 12 insertions, 6 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index b1412f018..7f77aa872 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -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)
{
@@ -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;
}
@@ -2163,4 +2164,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
memcpy(others->xi2mask[dev->id], mask, len);
RecalculateDeviceDeliverableEvents(win);
+
+ return Success;
}
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index 16eada7c8..672edab3b 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -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++;
}
diff --git a/include/exevents.h b/include/exevents.h
index ebe8ab589..39e1c70fe 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -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);
diff --git a/test/xi2/protocol-common.h b/test/xi2/protocol-common.h
index bf8b8754e..1ab35c92e 100644
--- a/test/xi2/protocol-common.h
+++ b/test/xi2/protocol-common.h
@@ -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);
diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c
index 9782cff5c..f314462b5 100644
--- a/test/xi2/protocol-xiselectevents.c
+++ b/test/xi2/protocol-xiselectevents.c
@@ -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.