Free scanFile when no longer needed Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index c72af74..b4bac2b 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -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 *