]> mj.ucw.cz Git - pciutils.git/commitdiff
Fixed FILE leak in the dump back-end
authorMartin Mares <mj@ucw.cz>
Mon, 10 Aug 2009 14:33:15 +0000 (16:33 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 10 Aug 2009 14:33:15 +0000 (16:33 +0200)
Closes https://bugzilla.novell.com/show_bug.cgi?id=529469

lib/dump.c

index 0196f6998cdd1ee838d19343242c424d8fdc1a8f..bdd1df655084fb5c532f29d147acffb6ba0df27b 100644 (file)
@@ -70,7 +70,10 @@ dump_init(struct pci_access *a)
     {
       char *z = strchr(buf, '\n');
       if (!z)
-       a->error("dump: line too long or unterminated");
+       {
+         fclose(f);
+         a->error("dump: line too long or unterminated");
+       }
       *z-- = 0;
       if (z >= buf && *z == '\r')
        *z-- = 0;
@@ -95,7 +98,10 @@ dump_init(struct pci_access *a)
                 sscanf(z, "%x", &j) == 1 && j < 256)
            {
              if (i >= 4096)
-               a->error("dump: At most 4096 bytes of config space are supported");
+               {
+                 fclose(f);
+                 a->error("dump: At most 4096 bytes of config space are supported");
+               }
              if (i >= dd->allocated)   /* Need to re-allocate the buffer */
                {
                  dump_alloc_data(dev, 4096);
@@ -111,9 +117,13 @@ dump_init(struct pci_access *a)
                z++;
            }
          if (*z)
-           a->error("dump: Malformed line");
+           {
+             fclose(f);
+             a->error("dump: Malformed line");
+           }
        }
     }
+  fclose(f);
 }
 
 static void