From b8023aeef9ae582429b48997652223bb99934b24 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Wed, 21 Feb 2024 22:32:32 -0500 Subject: [PATCH] Tokenizer: pad with 2 NULL bytes --- src/m_tokenizer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/m_tokenizer.c b/src/m_tokenizer.c index e1310f98f..8bb094cae 100644 --- a/src/m_tokenizer.c +++ b/src/m_tokenizer.c @@ -15,10 +15,13 @@ tokenizer_t *Tokenizer_Open(const char *inputString, size_t len, unsigned numTokens) { tokenizer_t *tokenizer = Z_Malloc(sizeof(tokenizer_t), PU_STATIC, NULL); - const size_t lenpan = len+1; + const size_t lenpan = 2; - tokenizer->zdup = malloc(lenpan); - tokenizer->zdup[len] = 0x00; + tokenizer->zdup = malloc(len+lenpan); + for (size_t i = 0; i < lenpan; i++) + { + tokenizer->zdup[len+i] = 0x00; + } tokenizer->input = M_Memcpy(tokenizer->zdup, inputString, len); tokenizer->startPos = 0;