[PATCH twm 1/3] Address a possible NULL pointer dereference
Jeremy Huddleston
jeremyhu at apple.com
Wed May 11 22:43:25 PDT 2011
menus.c:523:24: warning: Access to field 'w' results in a dereference of a null pointer (loaded from variable 'ActiveMenu')
if (XFindContext(dpy, ActiveMenu->w, ScreenContext, &context_data) == 0)
^~~~~~~~~~
Found-by: clang static analyzer
Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---
src/menus.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/menus.c b/src/menus.c
index bc688e6..34a3c8e 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -511,13 +511,16 @@ UpdateMenu()
if (Event.type != MotionNotify)
continue;
+
+ if (!ActiveMenu)
+ continue;
done = FALSE;
XQueryPointer( dpy, ActiveMenu->w, &JunkRoot, &JunkChild,
&x_root, &y_root, &x, &y, &JunkMask);
/* if we haven't recieved the enter notify yet, wait */
- if (ActiveMenu && !ActiveMenu->entered)
+ if (!ActiveMenu->entered)
continue;
if (XFindContext(dpy, ActiveMenu->w, ScreenContext, &context_data) == 0)
--
1.7.4.4
More information about the xorg-devel
mailing list