]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs : Fix memory leaks in ext2fs_extent_open()
authorManish Katiyar <mkatiyar@gmail.com>
Fri, 15 Aug 2008 20:56:43 +0000 (02:26 +0530)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 16 Aug 2008 14:52:25 +0000 (10:52 -0400)
Memory allocated for the ext2_extent_handle is not getting freed from
all the return paths in case of error. Below patch fixes it.

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

index 44d7d9b30371a03e51fbced15d74cd8be09c55a1..45c3dc8862aa57c01ad5c893e16e17f25046dd60 100644 (file)
@@ -222,12 +222,14 @@ extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
                handle->inode->i_flags |= EXT4_EXTENTS_FL;
        }
 
-       if (!(handle->inode->i_flags & EXT4_EXTENTS_FL))
-               return EXT2_ET_INODE_NOT_EXTENT;
+       if (!(handle->inode->i_flags & EXT4_EXTENTS_FL)) {
+               retval = EXT2_ET_INODE_NOT_EXTENT;
+               goto errout;
+       }
 
        retval = ext2fs_extent_header_verify(eh, sizeof(handle->inode->i_block));
        if (retval)
-               return (retval);
+               goto errout;
 
        handle->max_depth = ext2fs_le16_to_cpu(eh->eh_depth);
        handle->type = ext2fs_le16_to_cpu(eh->eh_magic);