xkbcomp/ast-build: fix memory leak when appending multi-keysyms `syms` was not freed. Signed-off-by: Ran Benita <ran234@gmail.com>
diff --git a/src/darray.h b/src/darray.h
index be0319f..5896d21 100644
--- a/src/darray.h
+++ b/src/darray.h
@@ -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 { \
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index eeef76a..58f97f9 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -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);