Skip to content

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

Closed
@1ndahous3

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions