compile-i386.c: fix a memory leak in sort_array()
PATCH 1/1 compile-i386.c: fix a memory leak in sort_array()
sort_array() locally allocates a list it. Let's free it before returning in order to avoid memory to leak.
Signed-off-by Martin Kepplinger <[email protected]>
--- compile-i386.c | 1 + 1 file changed, 1 insertion(+)
compile-i386.c +1 -0
@@ -1048,6 +1048,7 @@ static void sort_array(struct expression *expr) *THIS_ADDRESS (entry) = list[i++]; }END_FOR_EACH_PTR (entry); +free (list); }static void emit_array (struct symbol *sym)
Signature · 1 line
2.11.0
Quoted 4 lines · Martin Kepplinger
sort_array()locally allocates a list it. Let's free it before returning in order to avoid memory to leak.Signed-off-by Martin Kepplinger <[email protected]>
Applied. While I am reading the code in that function, I notice there is expression_list_size() which can get the size of the expression list.
There is also a sort_list() in sort.c which can simplify sort_array().
Chris