Commit 4b58ff78594e649b2af73b60cd9f82efe81fa529

Pierre Le Marre 2023-10-25T20:59:36

Fix memory leak in print_keymap The string buffer was not freed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/tools/compile-keymap.c b/tools/compile-keymap.c
index f49aa3c..034f389 100644
--- a/tools/compile-keymap.c
+++ b/tools/compile-keymap.c
@@ -244,8 +244,10 @@ print_keymap(struct xkb_context *ctx, const struct xkb_rule_names *rmlvo)
     if (keymap == NULL)
         return false;
 
-    printf("%s\n", xkb_keymap_get_as_string(keymap,
-                                            XKB_KEYMAP_FORMAT_TEXT_V1));
+    char *buf = xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1);
+    printf("%s\n", buf);
+    free(buf);
+
     xkb_keymap_unref(keymap);
     return true;
 }