]> xenbits.xensource.com Git - libvirt.git/commitdiff
tools: Fix memory leak
authorJohn Ferlan <jferlan@redhat.com>
Thu, 14 Apr 2016 13:55:21 +0000 (09:55 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Sat, 16 Apr 2016 12:04:14 +0000 (08:04 -0400)
Coverity found that commit id 'c661b675f' needed to create a cleanup
path to handle the closing of 'fp' if the virBitmapNewQuiet failed.

tools/virt-host-validate-common.c

index e182d0c5ba3391fb5ec7778d7710f50baf938d15..c476c951ac401cf4c002e398c77487d1559ba723 100644 (file)
@@ -194,13 +194,13 @@ int virHostValidateNamespace(const char *hvname,
 virBitmapPtr virHostValidateGetCPUFlags(void)
 {
     FILE *fp;
-    virBitmapPtr flags;
+    virBitmapPtr flags = NULL;
 
     if (!(fp = fopen("/proc/cpuinfo", "r")))
         return NULL;
 
     if (!(flags = virBitmapNewQuiet(VIR_HOST_VALIDATE_CPU_FLAG_LAST)))
-        return NULL;
+        goto cleanup;
 
     do {
         char line[1024];
@@ -246,6 +246,7 @@ virBitmapPtr virHostValidateGetCPUFlags(void)
         virStringFreeListCount(tokens, ntokens);
     } while (1);
 
+ cleanup:
     VIR_FORCE_FCLOSE(fp);
 
     return flags;