From fb606b06a9aedd668f233ab7915b831625b46328 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Apr 2012 17:07:56 +0300 Subject: [PATCH] Avoid use of partly initialized VModInfo in error path 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 --- src/xkbcomp/vmod.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c index adf7473..799185d 100644 --- a/src/xkbcomp/vmod.c +++ b/src/xkbcomp/vmod.c @@ -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; -- 2.34.1