Skip to content

Commit 966dbfc

Browse files
committed
Fix crash in deserializer on bad regexp
1 parent 7be9d99 commit 966dbfc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

quickjs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35361,7 +35361,12 @@ static JSValue JS_ReadRegExp(BCReaderState *s)
3536135361
return JS_EXCEPTION;
3536235362
}
3536335363

35364-
assert(!bc->is_wide_char);
35364+
if (bc->is_wide_char) {
35365+
js_free_string(ctx->rt, pattern);
35366+
js_free_string(ctx->rt, bc);
35367+
return JS_ThrowInternalError(ctx, "bad regexp bytecode");
35368+
}
35369+
3536535370
if (is_be())
3536635371
lre_byte_swap(bc->u.str8, bc->len, /*is_byte_swapped*/TRUE);
3536735372

tests/test_bjson.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ function bjson_test_fuzz()
232232
var corpus = [
233233
"EBAAAAAABGA=",
234234
"EObm5oIt",
235+
"EAARABMGBgYGBgYGBgYGBv////8QABEALxH/vy8R/78=",
235236
];
236237
for (var input of corpus) {
237238
var buf = base64decode(input);

0 commit comments

Comments
 (0)