]> git.ipfire.org Git - thirdparty/nftables.git/commit
parser_json: release buffer returned by json_dumps
authorSebastian Walz (sivizius) <sebastian.walz@secunet.com>
Mon, 19 Aug 2024 17:58:14 +0000 (19:58 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Jan 2025 00:35:36 +0000 (01:35 +0100)
commit974e090330d64d68db7315a27b761a3d8439245e
tree28d8ed88760633ec6f04f468435bee594b7d9609
parent36b8657a61d2de45ef8cd360ef2df5319b7151e7
parser_json: release buffer returned by json_dumps

commit 46700fbdbbbaab0d7db716fce3a438334c58ac9e upstream.

The signature of `json_dumps` is:

`char *json_dumps(const json_t *json, size_t flags)`:

It will return a pointer to an owned string, the caller must free it.
However, `json_error` just borrows the string to format it as `%s`, but
after printing the formatted error message, the pointer to the string is
lost and thus never freed.

Fixes: 586ad210368b ("libnftables: Implement JSON parser")
Signed-off-by: Sebastian Walz (sivizius) <sebastian.walz@secunet.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_json.c