summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-07-06 11:13:49 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-07-18 22:56:23 -0700
commit169805e1dc8743b37b00e24cf3a5eb8748f733ad (patch)
tree1a66e37222dd398f1150cfcc9ae40f6a4ecfd3a4 /src
parent1e362fac92c6688fb42b195ccad16d7a337a34c1 (diff)
Fix validation of ctrls parameter to XkbGetPerClientControls()
Nothing in the XKB spec states that the memory pointed to by ctrls has to be initialized to any given value when passed to the function, only that it is set by the function to the values returned by the X server: http://www.x.org/releases/X11R7.7/doc/libX11/XKB/xkblib.html#The_Miscellaneous_Per_client_Controls The check for the incoming value seems to be copied from XkbSetPerClientControls without explanation. Instead change it to checking if ctrls is non-NULL, since there's no point asking the X server to return a value the caller won't even see. Found while investigating report from cppcheck-1.65: [src/xkb/XKB.c:699] -> [src/xkb/XKB.c:719]: (warning) Possible null pointer dereference: ctrls - otherwise it is redundant to check it against null. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r--src/xkb/XKB.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/xkb/XKB.c b/src/xkb/XKB.c
index 6413ba27..03a89d07 100644
--- a/src/xkb/XKB.c
+++ b/src/xkb/XKB.c
@@ -696,9 +696,7 @@ XkbGetPerClientControls(Display *dpy, unsigned *ctrls)
if ((dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)) ||
- (*ctrls & ~(XkbPCF_GrabsUseXKBStateMask |
- XkbPCF_LookupStateWhenGrabbed |
- XkbPCF_SendEventUsesXKBState)))
+ (ctrls == NULL))
return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
@@ -716,10 +714,9 @@ XkbGetPerClientControls(Display *dpy, unsigned *ctrls)
}
UnlockDisplay(dpy);
SyncHandle();
- if (ctrls)
- *ctrls = (rep.value & (XkbPCF_GrabsUseXKBStateMask |
- XkbPCF_LookupStateWhenGrabbed |
- XkbPCF_SendEventUsesXKBState));
+ *ctrls = (rep.value & (XkbPCF_GrabsUseXKBStateMask |
+ XkbPCF_LookupStateWhenGrabbed |
+ XkbPCF_SendEventUsesXKBState));
return (True);
}