xkbcomp/ast-build: fix memory leak when appending multi-keysyms
authorRan Benita <ran234@gmail.com>
Tue, 12 Dec 2017 12:43:24 +0000 (14:43 +0200)
committerRan Benita <ran234@gmail.com>
Tue, 12 Dec 2017 12:44:01 +0000 (14:44 +0200)
`syms` was not freed.

Signed-off-by: Ran Benita <ran234@gmail.com>
src/darray.h
src/xkbcomp/ast-build.c

index be0319f..5896d21 100644 (file)
@@ -110,6 +110,9 @@ typedef darray (unsigned long)  darray_ulong;
 #define darray_copy(arr_to, arr_from) \
     darray_from_items((arr_to), (arr_from).item, (arr_from).size)
 
+#define darray_concat(arr_to, arr_from) \
+    darray_append_items((arr_to), (arr_from).item, (arr_from).size)
+
 /*** String buffer ***/
 
 #define darray_append_string(arr, str) do { \
index eeef76a..58f97f9 100644 (file)
@@ -226,14 +226,12 @@ ExprAppendKeysymList(ExprDef *expr, xkb_keysym_t sym)
 ExprDef *
 ExprAppendMultiKeysymList(ExprDef *expr, ExprDef *append)
 {
-    xkb_keysym_t *syms;
     unsigned nSyms = darray_size(expr->keysym_list.syms);
     unsigned numEntries = darray_size(append->keysym_list.syms);
 
     darray_append(expr->keysym_list.symsMapIndex, nSyms);
     darray_append(expr->keysym_list.symsNumEntries, numEntries);
-    darray_steal(append->keysym_list.syms, &syms, NULL);
-    darray_append_items(expr->keysym_list.syms, syms, numEntries);
+    darray_concat(expr->keysym_list.syms, append->keysym_list.syms);
 
     FreeStmt((ParseCommon *) &append);