_XtGetPerWidgetInput may return NULL
avoid possible NULL references

 Signed-off-by: walter harms <[email protected]>

---
 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

_______________________________________________
[email protected]: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.freedesktop.org/mailman/listinfo/xorg
Your subscription address: [email protected]

Reply via email to