summaryrefslogtreecommitdiff
path: root/vmod.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-11 09:17:56 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-01-03 11:02:11 -0800
commit0d22aac7bb50ff1f7588f78ec25e9fb62a7b2e5e (patch)
treece7373be16b3f6d25fa40ceeae179961ee22c4f8 /vmod.c
parentc7a5d1468c75adb2139d2c2facc73854f13b5ba3 (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.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/vmod.c b/vmod.c
index af71704..97448c0 100644
--- a/vmod.c
+++ b/vmod.c
@@ -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;
}