tree-sitter/test/runtime/lexer_test.cc
Phil Turnbull e7662c2213 Handle out-of-bound read in utf16_iterate
Also simplify the test so we call `utf16_iterate` directly. Calling
`utf16_iterate` via `SpyInput` and `ts_document_parse` doesn't seem to reliably
trigger the problem using valgrind.

valgrind also doesn't detect the problem if we use a string literal like:
  `utf16_iterate("", 1, &code_point);`
2017-07-17 13:57:12 -07:00

18 lines
325 B
C++

#include "test_helper.h"
#include "runtime/utf16.h"
START_TEST
describe("Lexer", [&]() {
it("handles truncated UTF16 data", [&]() {
uint8_t *content = new uint8_t[1];
*content = 'A';
int32_t code_point = 0;
utf16_iterate(content, 1, &code_point);
delete[] content;
});
});
END_TEST