From 6d498fe17dab48cfd8fc8a4da62a573b799e10ba Mon Sep 17 00:00:00 2001 From: fusion32 Date: Wed, 16 Jul 2025 17:22:39 -0300 Subject: fix most init and parsing bugs + critical bug with dynamic strings With an appropriate query manager, the server now starts up and seems to work but won't properly handle connections until we fix the problem with threads and signals described in `TODO.md`. --- src/strings.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/strings.cc') diff --git a/src/strings.cc b/src/strings.cc index d0bfe70..95471d6 100644 --- a/src/strings.cc +++ b/src/strings.cc @@ -183,8 +183,8 @@ void CleanupDynamicStrings(void){ if(Block->EntryType[i] == DYNAMIC_STRING_DELETED){ int StringOffset = Block->StringOffset[i]; char *String = &Block->Text[StringOffset]; - int StringLen = (int)strlen(String); - int StringEnd = StringOffset + StringLen + 1; + int StringSize = (int)strlen(String) + 1; + int StringEnd = StringOffset + StringSize; Block->EntryType[i] = DYNAMIC_STRING_FREE; if(StringEnd > DynamicBlockSize){ @@ -193,13 +193,14 @@ void CleanupDynamicStrings(void){ } if(StringEnd < DynamicBlockSize){ - memmove(String, String + StringEnd, DynamicBlockSize - StringEnd); + memmove(String, String + StringSize, DynamicBlockSize - StringEnd); } for(int j = 0; j < DynamicBlockEntries; j += 1){ if(Block->EntryType[j] != DYNAMIC_STRING_FREE - && Block->StringOffset[j] > StringOffset){ - Block->StringOffset[j] -= StringLen + 1; + && Block->StringOffset[j] > StringOffset){ + ASSERT(Block->StringOffset[j] >= StringEnd); + Block->StringOffset[j] -= StringSize; } } } -- cgit v1.2.3