From 828c52d22dca7ab2562da4fde2994b214bbcd56f Mon Sep 17 00:00:00 2001 From: Will Lillis Date: Sat, 29 Jun 2024 20:55:20 -0400 Subject: [PATCH 1/2] Update stack size check in tree_sitter_c_sharp_external_scanner_serialize() --- src/scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scanner.c b/src/scanner.c index dd54ba9..993a37f 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -62,7 +62,7 @@ void tree_sitter_c_sharp_external_scanner_destroy(void *payload) { unsigned tree_sitter_c_sharp_external_scanner_serialize(void *payload, char *buffer) { Scanner *scanner = (Scanner *)payload; - if (scanner->interpolation_stack.size * 4 > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) { + if ((scanner->interpolation_stack.size * 4) + 2 > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) { return 0; } From f0806131fac710c39cfba7f588f0dd1d89ae7a9d Mon Sep 17 00:00:00 2001 From: Will Lillis Date: Sat, 29 Jun 2024 22:46:03 -0400 Subject: [PATCH 2/2] Remove extraneous parens --- src/scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scanner.c b/src/scanner.c index 993a37f..50ba6f2 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -62,7 +62,7 @@ void tree_sitter_c_sharp_external_scanner_destroy(void *payload) { unsigned tree_sitter_c_sharp_external_scanner_serialize(void *payload, char *buffer) { Scanner *scanner = (Scanner *)payload; - if ((scanner->interpolation_stack.size * 4) + 2 > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) { + if (scanner->interpolation_stack.size * 4 + 2 > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) { return 0; }