From 822a00c4d508b54f650933a73ca5f4a3af9a7983 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 7 Sep 2023 21:07:00 -0800 Subject: Fix a couple important bugs (#4560) --- src/bun.js/bindings/bindings.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/bun.js/bindings/bindings.cpp') 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(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) -- cgit v1.2.3