From ebeafc50f3d8125bd77d601a26351b3eba3bc259 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 17 Aug 2009 10:53:42 +0200 Subject: [PATCH] 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 --- shlibs/blkid/src/cache.c | 4 +++- shlibs/blkid/src/verify.c | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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) { -- 2.39.5