diff options
authorChris Halse Rogers <>2012-01-05 01:22:39 +0000
committerKeith Packard <>2012-01-09 13:09:48 -0800
commitef492e9797b6d4f6bbc25e86bedc24477819fde7 (patch)
parentff891bbf68caefc22cabb541b6b56af086ac2280 (diff)
dix: Return BadWindow rather than BadMatch from dixLookupWindow
dixLookupWindow uses dixLookupDrawable internally, which returns BadMatch when the XID matches a non-Window drawable. Users of dixLookupWindow don't care about this, just that it's not a valid Window. This is a generalised version of the fix for X.Org Bug 23562, where GetProperty was incorrectly returning BadMatch. Auditing other window requests, all that I checked would incorrectly return BadMatch in these circumstances. An incomplete list of calls that could incorrectly return BadMatch is: ListProperties, SetSelectionOwner, {Destroy,Map,Unmap}{,Sub}Window. None of the callers of dixLookupWindow, except for GetProperty, check for BadMatch Signed-off-by: Christopher James Halse Rogers <> Reviewed-by: Daniel Stone <> Reviewed-by: Adam Jackson <> Signed-off-by: Keith Packard <>
1 files changed, 9 insertions, 1 deletions
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 2b5391f2d..da26dc144 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -224,7 +224,15 @@ dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access)
int rc;
rc = dixLookupDrawable((DrawablePtr*)pWin, id, client, M_WINDOW, access);
- return (rc == BadDrawable) ? BadWindow : rc;
+ /* dixLookupDrawable returns BadMatch iff id is a valid Drawable
+ but is not a Window. Users of dixLookupWindow expect a BadWindow
+ error in this case; they don't care that it's a valid non-Window XID */
+ if (rc == BadMatch)
+ rc = BadWindow;
+ /* Similarly, users of dixLookupWindow don't want BadDrawable. */
+ if (rc == BadDrawable)
+ rc = BadWindow;
+ return rc;