Skip to content

Commit

Permalink
Allocate the stack array if null
Browse files Browse the repository at this point in the history
  • Loading branch information
afroozeh committed Aug 1, 2024
1 parent fe73604 commit 3a47896
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3a47896

Please sign in to comment.