Whamcloud - gitweb
Fix memory leak in blkid library
authorTheodore Ts'o <tytso@mit.edu>
Wed, 7 Mar 2007 00:56:18 +0000 (19:56 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 7 Mar 2007 00:56:18 +0000 (19:56 -0500)
Addresses Debian Bug: #413661

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/blkid/ChangeLog
lib/blkid/devname.c
lib/blkid/probe.c

index b0a8098..a0890a2 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-06  Theodore Tso  <tytso@mit.edu>
+
+       * devname.c (dm_probe_all), probe.c (blkid_verify): Fix memory
+               leak.  (Addresses Debian Bug #413661)
+
 2006-09-24  Theodore Tso  <tytso@mit.edu>
 
        * devno.c (scan_dir): Don't follow symlinks when recursively
index f8f5f48..1350076 100644 (file)
@@ -305,6 +305,7 @@ static void dm_probe_all(blkid_cache cache, int only_if_new)
                probe_one(cache, device, dev, BLKID_PRI_DM, only_if_new);
 
 try_next:
+               free(device);
                next = names->next;
        } while (next);
 
index 0f16565..24592bf 100644 (file)
@@ -886,9 +886,9 @@ try_again:
        }
 
        if (!dev->bid_type) {
-               if (probe.fd >= 0) close(probe.fd);
                blkid_free_dev(dev);
-               return NULL;
+               dev = 0;
+               goto found_type;
        }
                
 found_type:
@@ -908,7 +908,8 @@ found_type:
                free(probe.sbbuf);
        if (probe.buf)
                free(probe.buf);
-       close(probe.fd);
+       if (probe.fd >= 0) 
+               close(probe.fd);
 
        return dev;
 }