json: don't leave dangling pointers on hlist
Florian Westphal
maintainerPATCH 1/1 json: don't leave dangling pointers on hlist
unshare -n tests/json_echo/run-test.py
[..]
Adding chain cfree(): double free detected in tcache 2
Aborted (core dumped)
The element must be deleted from the hlist prior to freeing it.
Fixes 389a0e1edc89a ("json: echo: Speedup seqnum_to_json()")
Signed-off-by Florian Westphal <[email protected]>
--- src/parser_json.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
src/parser_json.c +3 -1
@@ -3786,8 +3786,10 @@ static void json_cmd_assoc_free(void)for (i =0 ; i <CMD_ASSOC_HSIZE ; i++) {hlist_for_each_entry_safe (cur, pos, n, - &json_cmd_assoc_hash[i], hnode) + &json_cmd_assoc_hash[i], hnode) { +hlist_del (&cur->hnode);free (cur); + } } }
Signature · 1 line
2.26.2