Fixed memory leak when failing to lookup an index

When an index could not be used, the search context was not freed
pull/2/head
Jean-Pierre André 2017-02-11 10:29:39 +01:00
parent d69d2d9a1f
commit ea9b8a487c
2 changed files with 5 additions and 2 deletions

View File

@ -129,6 +129,7 @@ typedef struct {
VCN parent_vcn[MAX_PARENT_VCN]; /* entry's parent nodes */
int pindex; /* maximum it's the number of the parent nodes */
BOOL ib_dirty;
BOOL bad_index;
u32 block_size;
u8 vcn_size_bits;
} ntfs_index_context;

View File

@ -143,7 +143,7 @@ static void ntfs_index_ctx_free(ntfs_index_context *icx)
{
ntfs_log_trace("Entering\n");
if (!icx->entry)
if (!icx->bad_index && !icx->entry)
return;
if (icx->actx)
@ -719,7 +719,7 @@ int ntfs_index_lookup(const void *key, const int key_len, ntfs_index_context *ic
ret = ntfs_ie_lookup(key, key_len, icx, &ir->index, &vcn, &ie);
if (ret == STATUS_ERROR) {
err = errno;
goto err_out;
goto err_lookup;
}
icx->ir = ir;
@ -780,6 +780,8 @@ descend_into_child_node:
goto descend_into_child_node;
err_out:
icx->bad_index = TRUE; /* Force icx->* to be freed */
err_lookup:
free(ib);
if (!err)
err = EIO;