btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by cppcheck.
authorKenji Okimoto <okimoto@clear-code.com>
Thu, 15 Nov 2012 04:47:52 +0000 (13:47 +0900)
committerDavid Sterba <dsterba@suse.cz>
Thu, 17 Jan 2013 17:27:55 +0000 (18:27 +0100)
[utils.c:983]: (error) Memory leak: fullpath

Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
utils.c

diff --git a/utils.c b/utils.c
index b487be6..938f9a5 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -981,6 +981,7 @@ again:
        dirp = opendir(dirname);
        if (!dirp) {
                fprintf(stderr, "Unable to open %s for scanning\n", dirname);
+               free(fullpath);
                return -ENOENT;
        }
        while(1) {
@@ -1031,6 +1032,7 @@ again:
                free(pending);
                pending = list_entry(pending_list.next, struct pending_dir,
                                     list);
+               free(fullpath);
                list_del(&pending->list);
                closedir(dirp);
                dirp = NULL;
@@ -1039,6 +1041,7 @@ again:
        ret = 0;
 fail:
        free(pending);
+       free(fullpath);
        if (dirp)
                closedir(dirp);
        return ret;