Tokenizer_Open: pad the string with an NULL byte

This commit is contained in:
Alam Ed Arias 2024-02-21 21:53:12 -05:00
parent 8c7fe2ae95
commit da1b579cee
2 changed files with 4 additions and 2 deletions

View file

@ -15,8 +15,10 @@
tokenizer_t *Tokenizer_Open(const char *inputString, size_t len, unsigned numTokens) tokenizer_t *Tokenizer_Open(const char *inputString, size_t len, unsigned numTokens)
{ {
tokenizer_t *tokenizer = Z_Malloc(sizeof(tokenizer_t), PU_STATIC, NULL); tokenizer_t *tokenizer = Z_Malloc(sizeof(tokenizer_t), PU_STATIC, NULL);
const size_t lenpan = len+1;
tokenizer->zdup = malloc(len); tokenizer->zdup = malloc(lenpan);
tokenizer->zdup[len] = 0x00;
tokenizer->input = M_Memcpy(tokenizer->zdup, inputString, len); tokenizer->input = M_Memcpy(tokenizer->zdup, inputString, len);
tokenizer->startPos = 0; tokenizer->startPos = 0;

View file

@ -16,7 +16,7 @@
typedef struct Tokenizer typedef struct Tokenizer
{ {
void *zdup; char *zdup;
const char *input; const char *input;
unsigned numTokens; unsigned numTokens;
UINT32 *capacity; UINT32 *capacity;