Assert ts_parser_set_language in fuzz driver
This commit is contained in:
parent
c56c4affb2
commit
c41841f4e9
1 changed files with 6 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include <string.h>
|
||||
#include <cassert>
|
||||
#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<const char *>(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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue