]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Don't pass NULL to yajl_free()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 30 Mar 2020 08:37:09 +0000 (10:37 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 30 Mar 2020 14:11:13 +0000 (16:11 +0200)
Unfortunately, yajl_free() is not NOP on NULL. It really does
expect a valid pointer. Therefore, check whether the pointer we
want to pass to it is NULL or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virjson.c
tools/nss/libvirt_nss_leases.c
tools/nss/libvirt_nss_macs.c

index be472d49e442e9e5bb54fd5775325d6d87ea2507..dc662bf8e90b43a0d1c68c11adff21bb6abb0ba3 100644 (file)
@@ -1838,7 +1838,7 @@ virJSONValueFromString(const char *jsonstring)
     if (!hand) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Unable to create JSON parser"));
-        goto cleanup;
+        return NULL;
     }
 
     /* Yajl 2 is nice enough to default to rejecting trailing garbage. */
index 7c431e4d53c48b2d0ed4febd8335ebae4e646577..015bbc4ab64458153a362b600367d01591f7b1c7 100644 (file)
@@ -426,7 +426,8 @@ findLeases(const char *file,
         *addrs = NULL;
         *naddrs = 0;
     }
-    yajl_free(parser);
+    if (parser)
+        yajl_free(parser);
     free(parserState.entry.ipaddr);
     free(parserState.entry.macaddr);
     free(parserState.entry.hostname);
index 05d096a348057ef8c51671e379dbbd3e3d9d0860..d4b165eef61ae680b940b219611f87cdf8e6c8d0 100644 (file)
@@ -278,7 +278,8 @@ findMACs(const char *file,
         *macs = NULL;
         *nmacs = 0;
     }
-    yajl_free(parser);
+    if (parser)
+        yajl_free(parser);
     for (i = 0; i < parserState.entry.nmacs; i++)
         free(parserState.entry.macs[i]);
     free(parserState.entry.macs);