From bc44f58a8098d7a150cf0232d403a9251fbad734 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Sun, 5 Jan 2025 22:39:03 -0800 Subject: [PATCH] fix off-by-one size restriction in string chunk allocation; apply same fixes to ctrl entity string allocator --- src/ctrl/ctrl_core.c | 3 ++- src/raddbg/raddbg_core.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 2317b824c..402437d0b 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -676,7 +676,7 @@ ctrl_entity_string_alloc(CTRL_EntityStore *store, String8 string) n != 0; prev = n, n = n->next) { - if(n->size >= string.size+1) + if(n->size >= string.size) { if(prev == 0) { @@ -711,6 +711,7 @@ ctrl_entity_string_alloc(CTRL_EntityStore *store, String8 string) } U8 *chunk_memory = push_array(store->arena, U8, chunk_size); node = (CTRL_EntityStringChunkNode *)chunk_memory; + node->size = chunk_size; } // rjf: fill string & return diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index d54cbf9bf..f2e6a2ee3 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -1126,7 +1126,7 @@ rd_name_alloc(String8 string) n != 0; prev = n, n = n->next) { - if(n->size >= string.size+1) + if(n->size >= string.size) { if(prev == 0) {