Whamcloud - gitweb
libext2fs: fix potential memory leak in ext2fs_initialize()
authorManish Katiyar <mkatiyar@gmail.com>
Fri, 11 Jul 2008 18:42:57 +0000 (14:42 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 11 Jul 2008 18:45:58 +0000 (14:45 -0400)
If we fail doing ext2fs_allocate_block_bitmap() or
ext2fs_allocate_inode_bitmap() we directly goto cleanup and don't free
the memory allocated to buf.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/initialize.c

index 011656f..e9bfe49 100644 (file)
@@ -105,7 +105,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
        int             rsv_gdt;
        int             csum_flag;
        int             io_flags;
-       char            *buf;
+       char            *buf = 0;
        char            c;
 
        if (!param || !param->s_blocks_count)
@@ -429,6 +429,8 @@ ipg_retry:
        *ret_fs = fs;
        return 0;
 cleanup:
+       if (buf)
+               free(buf);
        ext2fs_free(fs);
        return retval;
 }