Skip to content

Commit 828c12b

Browse files
committed
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>
1 parent 07148f3 commit 828c12b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

json_tokener.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ struct json_tokener *json_tokener_new(void)
182182

183183
void json_tokener_free(struct json_tokener *tok)
184184
{
185+
if (!tok)
186+
return;
185187
json_tokener_reset(tok);
186188
if (tok->pb)
187189
printbuf_free(tok->pb);

0 commit comments

Comments
 (0)