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);`
This commit is contained in:
parent
035abc1e15
commit
e7662c2213
3 changed files with 23 additions and 13 deletions
|
|
@ -1,6 +1,11 @@
|
|||
#include "runtime/utf16.h"
|
||||
|
||||
int utf16_iterate(const uint8_t *string, size_t length, int32_t *code_point) {
|
||||
if (length < 2) {
|
||||
*code_point = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t *units = (uint16_t *)string;
|
||||
uint16_t unit = units[0];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue