From: Karel Zak Date: Mon, 17 Aug 2009 08:53:42 +0000 (+0200) Subject: libblkid: fix cache->probe memory leak X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebeafc50f3d8125bd77d601a26351b3eba3bc259;p=util-linux libblkid: fix cache->probe memory leak 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 Signed-off-by: Karel Zak --- diff --git a/shlibs/blkid/src/cache.c b/shlibs/blkid/src/cache.c index 01e4be06..acdf96dd 100644 --- a/shlibs/blkid/src/cache.c +++ b/shlibs/blkid/src/cache.c @@ -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); } diff --git a/shlibs/blkid/src/verify.c b/shlibs/blkid/src/verify.c index 40ab4c67..78dafe7e 100644 --- a/shlibs/blkid/src/verify.c +++ b/shlibs/blkid/src/verify.c @@ -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) {