aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/bindings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/bindings/bindings.cpp')
-rw-r--r--src/bun.js/bindings/bindings.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index 6413e0470..e46982aad 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -3144,11 +3144,16 @@ JSC__JSValue JSC__JSValue__getIfPropertyExistsImpl(JSC__JSValue JSValue0,
const unsigned char* arg1, uint32_t arg2)
{
+ JSValue value = JSC::JSValue::decode(JSValue0);
+ if (UNLIKELY(!value.isObject()))
+ return JSValue::encode({});
+
JSC::VM& vm = globalObject->vm();
- JSC::JSObject* object = JSC::JSValue::decode(JSValue0).asCell()->getObject();
- auto propertyName = JSC::PropertyName(
- JSC::Identifier::fromString(vm, reinterpret_cast<const LChar*>(arg1), (int)arg2));
- return JSC::JSValue::encode(object->getIfPropertyExists(globalObject, propertyName));
+ JSC::JSObject* object = value.getObject();
+ auto identifier = JSC::Identifier::fromString(vm, String(StringImpl::createWithoutCopying(arg1, arg2)));
+ auto property = JSC::PropertyName(identifier);
+
+ return JSC::JSValue::encode(object->getIfPropertyExists(globalObject, property));
}
JSC__JSValue JSC__JSValue__getIfPropertyExistsFromPath(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, JSC__JSValue arg1)