btrfs-progs: fix memory leak in btrfs-map-logical main()
authorByongho Lee <bhlee.kernel@gmail.com>
Thu, 27 Aug 2015 15:38:17 +0000 (00:38 +0900)
committerDavid Sterba <dsterba@suse.com>
Mon, 31 Aug 2015 17:25:14 +0000 (19:25 +0200)
In btrfs-map-logical main(), strdup() allocates memory to output_file,
but that memory is not freed.
So add missing free() calls before return.

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-map-logical.c

index a88e56e..d9fa6b2 100644 (file)
@@ -262,6 +262,7 @@ int main(int ac, char **av)
        root = open_ctree(dev, 0, 0);
        if (!root) {
                fprintf(stderr, "Open ctree failed\n");
+               free(output_file);
                exit(1);
        }
 
@@ -354,6 +355,7 @@ out_close_fd:
        if (output_file && out_fd != 1)
                close(out_fd);
 close:
+       free(output_file);
        close_ctree(root);
        if (ret < 0)
                ret = 1;