Whamcloud - gitweb
libext2fs: fix memory leak when drastically shrinking extent tree depth
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 14 Mar 2014 13:56:33 +0000 (09:56 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 14 Mar 2014 13:56:36 +0000 (09:56 -0400)
commita14f0a647b206622aff71432ba995dcfd8305a95
tree21e2dafb681cec0af495f58f2a800dae9b40acb5
parent8a6cc1aebd7e9b2e6d6624fa1f8539888da25fe4
libext2fs: fix memory leak when drastically shrinking extent tree depth

In ext2fs_extent_free(), h(andle)->max_depth is used as a loop
conditional variable to free all the h->path[].buf pointers.  However,
ext2fs_extent_delete() sets max_depth = 0 if we've removed everything
from the extent tree, which causes a subsequent _free() to leak some
buf pointers.  max_depth can be re-incremented when splitting extent
nodes, but there's no guarantee that it'll reach the old value before
the free.

Therefore, remember the size of h->paths[] separately, and use that
when freeing the extent handle.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/extent.c