From f9bf7ffee46956037a4389992d7803221967f82b Mon Sep 17 00:00:00 2001 From: kacpercwiklinski Date: Thu, 15 Aug 2024 09:58:42 +0200 Subject: [PATCH] Fix for temporary storage overflow warning Why do we need this? * Now the user is not warned about temp memory overflow which may introduce hard to debug bugs with memory management. Describe at least one specific and practical problem this solves for people developing a game * The buffer overflown and the pointers have been overwritten - undefined behavior, the pc fly into space. This fix fixes what the warning is meant to be. Warn in overflow situation to avoid potential bugs. Does this add complexity/friction for people making games? If so, how do you justify that? * There's no complexity in this PR. --- oogabooga/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oogabooga/memory.c b/oogabooga/memory.c index 89eb5eb..3d22f8d 100644 --- a/oogabooga/memory.c +++ b/oogabooga/memory.c @@ -647,6 +647,7 @@ void* talloc(u64 size) { if ((u8*)temporary_storage_pointer >= (u8*)temporary_storage+TEMPORARY_STORAGE_SIZE) { if (!has_warned_temporary_storage_overflow) { os_write_string_to_stdout(STR("WARNING: temporary storage was overflown, we wrap around at the start.\n")); + has_warned_temporary_storage_overflow = true; } temporary_storage_pointer = temporary_storage; return talloc(size);; @@ -657,7 +658,7 @@ void* talloc(u64 size) { void reset_temporary_storage() { temporary_storage_pointer = temporary_storage; - has_warned_temporary_storage_overflow = true; + has_warned_temporary_storage_overflow = false; } #endif // NOT OOGABOOGA_LINK_EXTERNAL_INSTANCE \ No newline at end of file