[PATCH nft] json: don't leave dangling pointers on hlist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



unshare -n tests/json_echo/run-test.py
[..]
Adding chain c
free(): 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 <fw@xxxxxxxxx>
---
 src/parser_json.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/parser_json.c b/src/parser_json.c
index 09e394dfc26d..f0486b77a225 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -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);
+		}
 	}
 }
 
-- 
2.26.2




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux