fix big growth path in arena; make rdi parse code slightly more robust to malformed rdis

This commit is contained in:
Ryan Fleury
2024-07-26 08:37:13 -07:00
parent 1f89d4de9e
commit 1d87c34dca
3 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -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;
+2 -1
View File
@@ -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;
@@ -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;