diff --git a/test/fuzz/fuzzer.cc b/test/fuzz/fuzzer.cc index 6fe1e4cb..5c247556 100644 --- a/test/fuzz/fuzzer.cc +++ b/test/fuzz/fuzzer.cc @@ -1,4 +1,5 @@ #include +#include #include "tree_sitter/runtime.h" void test_log(void *payload, TSLogType type, const char *string) { } @@ -13,7 +14,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { const char *str = reinterpret_cast(data); TSParser *parser = ts_parser_new(); - ts_parser_set_language(parser, TS_LANG()); + + // This can fail if the language version doesn't match the runtime version + bool language_ok = ts_parser_set_language(parser, TS_LANG()); + assert(language_ok); + ts_parser_halt_on_error(parser, TS_HALT_ON_ERROR); TSTree *tree = ts_parser_parse_string(parser, NULL, str, size);