]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Handle NULL gracefully in json_tokener_free 879/head
authorJán Tomko <jtomko@redhat.com>
Wed, 6 Nov 2024 14:19:04 +0000 (15:19 +0100)
committerJán Tomko <jtomko@redhat.com>
Wed, 6 Nov 2024 14:23:00 +0000 (15:23 +0100)
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>
json_tokener.c

index c831f8a5d31c4719ae14743cb5a6d584ba046238..4453c89714e3ee71bda9ec97cb94a989bb0577a2 100644 (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);