Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arena is destroyed even if not created due to memory allocation failure #1673

Closed
1ndahous3 opened this issue Apr 2, 2022 · 0 comments
Closed

Comments

@1ndahous3
Copy link
Contributor

Error while allocating memory for arena:

yara/libyara/arena.c

Lines 227 to 235 in 09027e5

int yr_arena_create(
uint32_t num_buffers,
size_t initial_buffer_size,
YR_ARENA** arena)
{
YR_ARENA* new_arena = (YR_ARENA*) yr_calloc(1, sizeof(YR_ARENA));
if (new_arena == NULL)
return ERROR_INSUFFICIENT_MEMORY;

Then unconditionally destroys the arena which is nullptr:

yara/libyara/compiler.c

Lines 283 to 288 in 09027e5

YR_API void yr_compiler_destroy(YR_COMPILER* compiler)
{
yr_arena_release(compiler->arena);
if (compiler->automaton != NULL)
yr_ac_automaton_destroy(compiler->automaton);

Detected by the Application Verifier (Windows) with the low resource simulation feature:
image

@plusvic plusvic closed this as completed in 8fbf255 Apr 4, 2022
plusvic added a commit that referenced this issue Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant