From e6e59f6e8d4eaea596399b66315365480293d6d8 Mon Sep 17 00:00:00 2001 From: Seonghyun Kim Date: Tue, 16 Jul 2024 10:35:51 +0900 Subject: [PATCH] RegExp.prototype.compile should not accept sub-class of RegExp Signed-off-by: Seonghyun Kim --- src/builtins/BuiltinRegExp.cpp | 4 ++++ tools/test/test262/excludelist.orig.xml | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/builtins/BuiltinRegExp.cpp b/src/builtins/BuiltinRegExp.cpp index 5233de2c0..c92cda719 100644 --- a/src/builtins/BuiltinRegExp.cpp +++ b/src/builtins/BuiltinRegExp.cpp @@ -203,6 +203,10 @@ static Value builtinRegExpCompile(ExecutionState& state, Value thisValue, size_t Optional proto = thisValue.asObject()->getPrototypeObject(state); Context* calleeContext = state.resolveCallee()->codeBlock()->context(); + if (!proto || !proto->isRegExpPrototypeObject()) { + ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, ErrorObject::Messages::GlobalObject_ThisNotRegExpObject); + } + bool match = false; while (proto) { Value c = proto->getOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().constructor)).value(state, proto.value()); diff --git a/tools/test/test262/excludelist.orig.xml b/tools/test/test262/excludelist.orig.xml index 4f57a3d8a..e68130990 100644 --- a/tools/test/test262/excludelist.orig.xml +++ b/tools/test/test262/excludelist.orig.xml @@ -31,7 +31,6 @@ ICU 67 returns wrong result with -0.0001 ICU 67 returns wrong result with -0.0001 - TODO TODO TODO TODO