Fixed a hash collision causing null variables to be overwritten

Andrew, don't you dare run my code through a clanker again or I'll hunt
your Canuck ass down and beat you with a hockey stick.
This commit is contained in:
2026-05-26 17:52:07 +10:00
parent b0387edeb0
commit 69175e801a
9 changed files with 24 additions and 10 deletions
+3 -2
View File
@@ -78,6 +78,7 @@ static void emitByte(unsigned char** handle, unsigned int* capacity, unsigned in
((unsigned char*)(*handle))[(*count)++] = byte;
}
//BUG: There might be issues here when compiled on big-endian platforms
static void emitInt(unsigned char** handle, unsigned int* capacity, unsigned int* count, unsigned int bytes) {
char* ptr = (char*)&bytes;
emitByte(handle, capacity, count, *(ptr++));
@@ -200,8 +201,8 @@ static unsigned int emitParameters(Toy_Bytecode* mb, Toy_Ast* ast) {
}
//the address within the data section
char buffer[128];
snprintf(buffer, 128, "%.*s", ast->varDeclare.name->info.length, ast->varDeclare.name->leaf.data);
char buffer[256];
snprintf(buffer, 256, "%.*s", ast->varDeclare.name->info.length, ast->varDeclare.name->leaf.data);
unsigned int dataAddr = emitCStringToData(&(mb->data), &(mb->dataCapacity), &(mb->dataCount), buffer);
//check the param index for that entry i.e. don't reuse parameter names