diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tokenizer.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tokenizer.c b/src/tokenizer.c index f2f52ad..9077bb9 100644 --- a/src/tokenizer.c +++ b/src/tokenizer.c @@ -585,9 +585,9 @@ TokenizerError tokenizer_create_error(Tokenizer *self, int index, const char *fm result.index = index; result.str = NULL; - ignore_result_int(scoped_allocator_alloc(self->allocator, bytes_copied, (void**)&result.str)); - if(result.str) - am_memcpy(result.str, buffer, bytes_copied); + ignore_result_int(scoped_allocator_alloc(self->allocator, bytes_copied + 1, (void**)&result.str)); + if(result.str && bytes_copied > 0) + am_memcpy(result.str, buffer, bytes_copied + 1); return result; } |