Handle NULL gracefully in json_tokener_free

Similarly to glibc's free, make json_tokener_free(NULL)
a no-op, to simplify cleanup paths.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Ján Tomko
2024-11-06 15:19:04 +01:00
parent 07148f33a1
commit 828c12b226

View File

@@ -182,6 +182,8 @@ struct json_tokener *json_tokener_new(void)
void json_tokener_free(struct json_tokener *tok)
{
if (!tok)
return;
json_tokener_reset(tok);
if (tok->pb)
printbuf_free(tok->pb);