Avoid use of partly initialized VModInfo in error path
authorRan Benita <ran234@gmail.com>
Sun, 1 Apr 2012 14:07:56 +0000 (17:07 +0300)
committerDaniel Stone <daniel@fooishbar.org>
Mon, 2 Apr 2012 12:09:06 +0000 (13:09 +0100)
Such as:

Compiling path: ./test/data/bad.xkb  mapName:
==1300== Conditional jump or move depends on uninitialised value(s)
==1300==    at 0x4E46166: HandleVModDef (vmod.c:90)
==1300==    by 0x4E3FEC9: HandleKeyTypesFile (keytypes.c:1035)
==1300==    by 0x4E3FBE1: HandleIncludeKeyTypes.constprop.11 (keytypes.c:387)
==1300==    by 0x4E401DD: HandleKeyTypesFile (keytypes.c:1022)
==1300==    by 0x4E3FBE1: HandleIncludeKeyTypes.constprop.11 (keytypes.c:387)
==1300==    by 0x4E401DD: HandleKeyTypesFile (keytypes.c:1022)
==1300==    by 0x4E4026F: CompileKeyTypes (keytypes.c:1150)
==1300==    by 0x4E3DF9B: CompileKeymap (keymap.c:169)
==1300==    by 0x4E465E9: compile_keymap (xkbcomp.c:205)
==1300==    by 0x4E46BE4: xkb_compile_keymap_from_file (xkbcomp.c:290)
==1300==    by 0x400B37: test_file (filecomp.c:47)
==1300==    by 0x4008E3: main (filecomp.c:90)
==1300==  Uninitialised value was created by a stack allocation
==1300==    at 0x4E3FB3F: HandleIncludeKeyTypes.constprop.11 (keytypes.c:366)

Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/vmod.c

index adf7473..799185d 100644 (file)
@@ -47,12 +47,15 @@ ClearVModInfo(VModInfo * info, struct xkb_desc * xkb)
 {
     int i;
 
+    info->newlyDefined = info->defined = info->available = 0;
+
     if (XkbcAllocNames(xkb, XkbVirtualModNamesMask, 0) != Success)
         return;
+
     if (XkbcAllocServerMap(xkb, XkbVirtualModsMask, 0) != Success)
         return;
+
     info->xkb = xkb;
-    info->newlyDefined = info->defined = info->available = 0;
     if (xkb && xkb->names)
     {
         int bit;