[PATCH libXt] fix NULL check

walter harms wharms at bfs.de
Tue Oct 26 04:46:32 PDT 2010


_XtGetPerWidgetInput may return NULL
avoid possible NULL references

 Signed-off-by: walter harms <wharms at bfs.de>

---
 src/Keyboard.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/Keyboard.c b/src/Keyboard.c
index 9c8065b..ef27399 100644
--- a/src/Keyboard.c
+++ b/src/Keyboard.c
@@ -727,18 +727,21 @@ static void QueryEventMask(
      */
     Widget ancestor = (Widget)client_data;
     XtPerWidgetInput pwi = _XtGetPerWidgetInput(ancestor, FALSE);
-    Widget target = pwi->queryEventDescendant;

-    /* use of 'target' is non-standard hackery; allows focus to non-widget */
-    if (pwi && (pwi->focusKid == target)) {
+    if (pwi) {
+      Widget target = pwi->queryEventDescendant;
+
+      /* use of 'target' is non-standard hackery; allows focus to non-widget */
+      if ( pwi->focusKid == target ) {
 	AddFocusHandler(ancestor, target, pwi,
 			_XtGetPerWidgetInput(GetShell(ancestor), TRUE),
 			_XtGetPerDisplayInput(XtDisplay(ancestor)),
 			(EventMask)0);
+      }
+      XtRemoveEventHandler(widget, XtAllEvents, True,
+			   QueryEventMask, client_data);
+      pwi->map_handler_added = FALSE;
     }
-    XtRemoveEventHandler(widget, XtAllEvents, True,
-			 QueryEventMask, client_data);
-    pwi->map_handler_added = FALSE;
 }


-- 
1.6.0.2




More information about the xorg mailing list