Pre-allocate tokenbuf for string parser (#3485)

Fixes #3483
This commit is contained in:
Fabian Fleischer authored and GitHub committed 2026-02-28 15:45:16 +01:00
1 parent 061fd14d74
commit 2ad99a6c70
1 file changed
+3 -2
+3 -2
View File
@@ -79,8 +79,9 @@ static void parser_init(struct jv_parser* p, int flags) {
p->last_seen = JV_LAST_NONE; p->last_seen = JV_LAST_NONE;
p->output = jv_invalid(); p->output = jv_invalid();
p->next = jv_invalid(); p->next = jv_invalid();
p->tokenbuf = 0; p->tokenlen = 256;
p->tokenlen = p->tokenpos = 0; p->tokenbuf = jv_mem_alloc(p->tokenlen);
p->tokenpos = 0;
if ((p->flags & JV_PARSE_SEQ)) if ((p->flags & JV_PARSE_SEQ))
p->st = JV_PARSER_WAITING_FOR_RS; p->st = JV_PARSER_WAITING_FOR_RS;
else else