]> err.no Git - util-linux/commitdiff
libblkid: fix cache->probe memory leak
authorKarel Zak <kzak@redhat.com>
Mon, 17 Aug 2009 08:53:42 +0000 (10:53 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Aug 2009 08:56:05 +0000 (10:56 +0200)
Fixes:

 * stupid bug, blkid_put_cache() does not deallocate the probe struct

 * the cache->probe initialization in verify.c should be also more
   robust

Reported-By: Jean-Pierre Demailly <Jean-Pierre.Demailly@ujf-grenoble.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/cache.c
shlibs/blkid/src/verify.c

index 01e4be061fd15db3549405454a84d26a7f86973d..acdf96ddebcc21c05f7d4dc372c6dfb4f67b9066 100644 (file)
@@ -181,8 +181,10 @@ void blkid_put_cache(blkid_cache cache)
                }
                blkid_free_tag(tag);
        }
-       free(cache->bic_filename);
 
+       blkid_free_probe(cache->probe);
+
+       free(cache->bic_filename);
        free(cache);
 }
 
index 40ab4c672e0fc13e6b1bd07d19e1218c9151744b..78dafe7e68cc9a1d48ffc842e7ad3b4676ccb5f9 100644 (file)
@@ -87,8 +87,13 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
                   (unsigned long)st.st_mtime, (unsigned long)diff));
 
 
-       if (!cache->probe)
+       if (!cache->probe) {
                cache->probe = blkid_new_probe();
+               if (!cache->probe) {
+                       blkid_free_dev(dev);
+                       return NULL;
+               }
+       }
 
        fd = open(dev->bid_name, O_RDONLY);
        if (fd < 0) {