aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-07-06 11:13:49 -0700
committerUlrich Sibiller <uli42@gmx.de>2016-10-19 21:40:29 +0200
commitf20f91ee89607537dfc6bfaec05d18e9830bea13 (patch)
tree5fec29879aeb7ff03b7b33e699834a0b53e5ad6a /nx-X11/lib/X11
parent37b8d68832cfd6f20b321d9d7e757027c75677f2 (diff)
downloadnx-libs-f20f91ee89607537dfc6bfaec05d18e9830bea13.tar.gz
nx-libs-f20f91ee89607537dfc6bfaec05d18e9830bea13.tar.bz2
nx-libs-f20f91ee89607537dfc6bfaec05d18e9830bea13.zip
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: [nx-X11/lib/X11/XKB.c:699] -> [nx-X11/lib/X11/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> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib/X11')
-rw-r--r--nx-X11/lib/X11/XKB.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/nx-X11/lib/X11/XKB.c b/nx-X11/lib/X11/XKB.c
index 7f1b233aa..7ecd39706 100644
--- a/nx-X11/lib/X11/XKB.c
+++ b/nx-X11/lib/X11/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);
}