aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-27 06:16:52 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-27 06:16:52 -0800
commit74e87b5a8a94a59bbfa32bba554503921c74c68c (patch)
tree1ce53ff09e376224e1598dbff8b669e2b4be3175 /src
parent819a63e3ec905d1f013ff9c7b7480ff649b78477 (diff)
downloadbun-74e87b5a8a94a59bbfa32bba554503921c74c68c.tar.gz
bun-74e87b5a8a94a59bbfa32bba554503921c74c68c.tar.zst
bun-74e87b5a8a94a59bbfa32bba554503921c74c68c.zip
Fix crash in OnigurumaRegExp getters
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/OnigurumaRegExp.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bun.js/bindings/OnigurumaRegExp.cpp b/src/bun.js/bindings/OnigurumaRegExp.cpp
index c9dedb09c..446a576e8 100644
--- a/src/bun.js/bindings/OnigurumaRegExp.cpp
+++ b/src/bun.js/bindings/OnigurumaRegExp.cpp
@@ -465,12 +465,18 @@ JSC_DEFINE_CUSTOM_GETTER(onigurumaRegExpProtoGetterFlags, (JSGlobalObject * glob
JSC_DEFINE_CUSTOM_GETTER(onigurumaRegExpProtoGetterLastIndex, (JSGlobalObject * globalObject, EncodedJSValue encodedThis, PropertyName))
{
auto* thisValue = jsDynamicCast<OnigurumaRegEx*>(JSValue::decode(encodedThis));
+ if (UNLIKELY(!thisValue)) {
+ return JSValue::encode(jsUndefined());
+ }
return JSValue::encode(jsNumber(thisValue->m_lastIndex));
}
JSC_DEFINE_CUSTOM_SETTER(onigurumaRegExpProtoSetterLastIndex, (JSGlobalObject * globalObject, EncodedJSValue encodedThis, EncodedJSValue encodedValue, PropertyName))
{
auto* thisValue = jsDynamicCast<OnigurumaRegEx*>(JSValue::decode(encodedThis));
+ if (UNLIKELY(!thisValue)) {
+ return JSValue::encode(jsUndefined());
+ }
auto throwScope = DECLARE_THROW_SCOPE(globalObject->vm());
JSValue value = JSValue::decode(encodedValue);
if (!value.isAnyInt()) {