]> git.ipfire.org Git - thirdparty/nftables.git/commit
json: Fix for memleak in __binop_expr_json
authorPhil Sutter <phil@nwl.cc>
Wed, 24 Apr 2024 21:35:00 +0000 (23:35 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 24 Apr 2024 21:52:06 +0000 (23:52 +0200)
commita0a15e4dd0576bc4efd9b01fdd4ee1c565effac9
treef062c5c9b0bc4c0444541fb8ae55905769e03df3
parent4955ae1a81b73f9a61b7fbf1a73e11544513548e
json: Fix for memleak in __binop_expr_json

When merging the JSON arrays generated for LHS and RHS of nested binop
expressions, the emptied array objects leak if their reference is not
decremented.

Fix this and tidy up other spots which did it right already by
introducing a json_array_extend wrapper.

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Fixes: 0ac39384fd9e4 ("json: Accept more than two operands in binary expressions")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/json.c