diff --git a/src/base/base_arena.c b/src/base/base_arena.c index 1ced0310..28eb6e83 100644 --- a/src/base/base_arena.c +++ b/src/base/base_arena.c @@ -87,7 +87,7 @@ arena_push(Arena *arena, U64 size, U64 align) { U64 res_size = current->res_size; U64 cmt_size = current->cmt_size; - if(size > res_size) + if(size + ARENA_HEADER_SIZE > res_size) { res_size = size + ARENA_HEADER_SIZE; cmt_size = size + ARENA_HEADER_SIZE; diff --git a/src/lib_rdi_format/rdi_format_parse.c b/src/lib_rdi_format/rdi_format_parse.c index a7173610..5d981b3e 100644 --- a/src/lib_rdi_format/rdi_format_parse.c +++ b/src/lib_rdi_format/rdi_format_parse.c @@ -98,7 +98,8 @@ rdi_section_raw_data_from_kind(RDI_Parsed *rdi, RDI_SectionKind kind, RDI_Sectio result = &rdi_nil_element_union; *size_out = rdi_section_element_size_table[kind]; #endif - if(0 <= kind && kind < rdi->sections_count) + if(0 <= kind && kind < rdi->sections_count && + rdi->sections[kind].off < rdi->raw_data_size) { result = rdi->raw_data+rdi->sections[kind].off; *size_out = rdi->sections[kind].encoded_size; diff --git a/src/metagen/metagen_base/metagen_base_arena.c b/src/metagen/metagen_base/metagen_base_arena.c index 1ced0310..28eb6e83 100644 --- a/src/metagen/metagen_base/metagen_base_arena.c +++ b/src/metagen/metagen_base/metagen_base_arena.c @@ -87,7 +87,7 @@ arena_push(Arena *arena, U64 size, U64 align) { U64 res_size = current->res_size; U64 cmt_size = current->cmt_size; - if(size > res_size) + if(size + ARENA_HEADER_SIZE > res_size) { res_size = size + ARENA_HEADER_SIZE; cmt_size = size + ARENA_HEADER_SIZE;