From 4d9c861176f85bf688c2860c1e41801293b384cf Mon Sep 17 00:00:00 2001 From: szaka Date: Sat, 2 Feb 2008 16:55:04 +0000 Subject: [PATCH] ntfs_index_lookup(): fix potential double free()'s on error paths --- libntfs-3g/index.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/libntfs-3g/index.c b/libntfs-3g/index.c index eb8a7476..d7359eb8 100644 --- a/libntfs-3g/index.c +++ b/libntfs-3g/index.c @@ -147,18 +147,14 @@ static void ntfs_index_ctx_free(ntfs_index_context *icx) if (icx->actx) ntfs_attr_put_search_ctx(icx->actx); - if (icx->is_in_root) { - if (icx->ia_na) - ntfs_attr_close(icx->ia_na); - return; - } - - if (icx->ib_dirty) { - /* FIXME: Error handling!!! */ - ntfs_ib_write(icx, icx->ib); + if (!icx->is_in_root) { + if (icx->ib_dirty) { + /* FIXME: Error handling!!! */ + ntfs_ib_write(icx, icx->ib); + } + free(icx->ib); } - free(icx->ib); ntfs_attr_close(icx->ia_na); } @@ -775,8 +771,6 @@ descend_into_child_node: goto descend_into_child_node; err_out: - if (icx->ia_na) - ntfs_attr_close(icx->ia_na); free(ib); if (!err) err = EIO;