diff --git a/src/scanner.c b/src/scanner.c index f782397..560b8c5 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -509,6 +509,9 @@ unsigned tree_sitter_kotlin_external_scanner_serialize(void *payload, char *buff void tree_sitter_kotlin_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) { Stack *stack = (Stack *)payload; if (length > 0) { + if (!stack->contents) { + stack->contents = malloc(length); + } memcpy(stack->contents, buffer, length); stack->size = length; } else {