[PATCH 2/3] libX11/XKBNames.c fix: dereferenced before check

walter harms wharms at bfs.de
Wed Jun 4 08:10:20 PDT 2014


* Do not use variables before checked for NULL.

Signed-off-by: Harms <wharms at bfs,de>
---
 src/xkb/XKBNames.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/xkb/XKBNames.c b/src/xkb/XKBNames.c
index 3f2fd39..5a3fb6f 100644
--- a/src/xkb/XKBNames.c
+++ b/src/xkb/XKBNames.c
@@ -778,9 +778,14 @@ XkbNoteNameChanges(XkbNameChangesPtr old,
 {
     int first, last, old_last, new_last;

-    wanted &= new->changed;
-    if ((old == NULL) || (new == NULL) || (wanted == 0))
+    if ((old == NULL) || (new == NULL))
         return;
+
+    wanted &= new->changed;
+
+    if (wanted == 0)
+	return;
+
     if (wanted & XkbKeyTypeNamesMask) {
         if (old->changed & XkbKeyTypeNamesMask) {
             new_last = (new->first_type + new->num_types - 1);
-- 
1.8.4.5



More information about the xorg-devel mailing list