Skip to content

Commit 3b5b6e6

Browse files
committed
Fix memory leak when _yr_process_attach fails.
Closes #1070.
1 parent ac0d090 commit 3b5b6e6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libyara/proc.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ YR_API int yr_process_open_iterator(
5656
context->current_block.fetch_data = yr_process_fetch_memory_block_data;
5757
context->proc_info = NULL;
5858

59-
return _yr_process_attach(pid, context);
59+
FAIL_ON_ERROR_WITH_CLEANUP(
60+
_yr_process_attach(pid, context),
61+
yr_free(context));
62+
63+
return ERROR_SUCCESS;
6064
}
6165

6266

0 commit comments

Comments
 (0)