diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-11 09:17:56 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-03 11:02:11 -0800 |
commit | 0d22aac7bb50ff1f7588f78ec25e9fb62a7b2e5e (patch) | |
tree | ce7373be16b3f6d25fa40ceeae179961ee22c4f8 /vmod.c | |
parent | c7a5d1468c75adb2139d2c2facc73854f13b5ba3 (diff) |
FindKeypadVMod: check xkb is not NULL before dereference, not after
As found by cppcheck:
vmod.c:232:26: warning: Either the condition 'xkb' is redundant or there
is possible null pointer dereference: xkb. [nullPointerRedundantCheck]
name = XkbInternAtom(xkb->dpy, "NumLock", False);
^
vmod.c:233:10: note: Assuming that condition 'xkb' is not redundant
if ((xkb) && LookupVModIndex((XPointer) xkb, None, name, TypeInt, &rtrn))
^
vmod.c:232:26: note: Null pointer dereference
name = XkbInternAtom(xkb->dpy, "NumLock", False);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'vmod.c')
-rw-r--r-- | vmod.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -226,13 +226,14 @@ LookupVModMask(XPointer priv, int FindKeypadVMod(XkbDescPtr xkb) { - Atom name; - ExprResult rtrn; + if (xkb) { + Atom name = XkbInternAtom(xkb->dpy, "NumLock", False); + ExprResult rtrn; - name = XkbInternAtom(xkb->dpy, "NumLock", False); - if ((xkb) && LookupVModIndex((XPointer) xkb, None, name, TypeInt, &rtrn)) - { - return rtrn.ival; + if (LookupVModIndex((XPointer) xkb, None, name, TypeInt, &rtrn)) + { + return rtrn.ival; + } } return -1; } |