Free scanFile when no longer needed
authorRan Benita <ran234@gmail.com>
Thu, 1 Mar 2012 19:03:13 +0000 (21:03 +0200)
committerRan Benita <ran234@gmail.com>
Sat, 3 Mar 2012 22:04:04 +0000 (00:04 +0200)
Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/xkbcomp.c

index c72af74..b4bac2b 100644 (file)
@@ -196,7 +196,7 @@ struct xkb_desc *
 xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
 {
     XkbFile *file, *mapToUse;
-    struct xkb_desc * xkb;
+    struct xkb_desc * xkb = NULL;
 
     uSetErrorFile(NULL);
 
@@ -222,24 +222,22 @@ xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
 
     if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
         ERROR("failed to compile keymap\n");
-        goto unwind_xkb;
+        XkbcFreeKeyboard(xkb);
+        xkb = NULL;
     }
 
-    FreeXKBFile(file);
-    return xkb;
-unwind_xkb:
-    XkbcFreeKeyboard(xkb);
 unwind_file:
     FreeXKBFile(file);
+    free(scanFile);
 fail:
-    return NULL;
+    return xkb;
 }
 
 static struct xkb_desc *
 compile_keymap(XkbFile *file, const char *mapName)
 {
     XkbFile *mapToUse;
-    struct xkb_desc * xkb;
+    struct xkb_desc * xkb = NULL;
 
     /* Find map to use */
     if (!(mapToUse = XkbChooseMap(file, mapName)))
@@ -263,17 +261,14 @@ compile_keymap(XkbFile *file, const char *mapName)
 
     if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
         ERROR("failed to compile keymap\n");
-        goto unwind_xkb;
+        XkbcFreeKeyboard(xkb);
+        xkb = NULL;
     }
 
-    FreeXKBFile(file);
-    return xkb;
-unwind_xkb:
-    XkbcFreeKeyboard(xkb);
 unwind_file:
     FreeXKBFile(file);
-
-    return NULL;
+    free(scanFile);
+    return xkb;
 }
 
 struct xkb_desc *