]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Resolve memory leaks in virLogParse{Output|Filter}
authorJohn Ferlan <jferlan@redhat.com>
Mon, 10 Oct 2016 11:18:30 +0000 (07:18 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 10 Oct 2016 19:27:45 +0000 (15:27 -0400)
In both virLogParseOutput and virLogParseFilter, rather than returning
NULL, goto cleanup since it's possible that for each the first condition
passes, but the || condition doesn't and thus we leak memory.

src/util/virlog.c

index 14ee7010f0bdbace367ee2323f2dbf606f7bcfdd..52b0eea30b27c2ff2cf07e05a55d3c3d060cdbef 100644 (file)
@@ -1466,7 +1466,7 @@ virLogParseOutput(const char *src)
     if (!(tokens = virStringSplitCount(src, ":", 0, &count)) || count < 2) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("Malformed format for output '%s'"), src);
-        return NULL;
+        goto cleanup;
     }
 
     if (virStrToLong_uip(tokens[0], NULL, 10, &prio) < 0 ||
@@ -1575,7 +1575,7 @@ virLogParseFilter(const char *src)
     if (!(tokens = virStringSplitCount(src, ":", 0, &count)) || count != 2) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("Malformed format for filter '%s'"), src);
-        return NULL;
+        goto cleanup;
     }
 
     if (virStrToLong_uip(tokens[0], NULL, 10, &prio) < 0 ||