[PATCH]libXt-1.0.8/src/Keyboard.c fix NULL-pointer check

walter harms wharms at bfs.de
Fri Oct 22 10:43:17 PDT 2010


_XtGetPerWidgetInput() can return NULL, move check so that
pwi->queryEventDescendant and friends are covered

re,
 wh

Signed-off-by: wharms at bfs.de


--- libXt-1.0.8/src/Keyboard.c.org	2010-10-20 20:26:05.000000000 +0200
+++ libXt-1.0.8/src/Keyboard.c	2010-10-20 20:40:35.000000000 +0200
@@ -729,18 +729,21 @@
      */
     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;
 }




More information about the xorg-devel mailing list