diff options
author | 2023-09-07 21:07:00 -0800 | |
---|---|---|
committer | 2023-09-07 21:07:00 -0800 | |
commit | 822a00c4d508b54f650933a73ca5f4a3af9a7983 (patch) | |
tree | 8c0d1e7ce7e9c230f97bcc17c3169647267b1eec /src/bun.js/bindings/bindings.cpp | |
parent | f6a621f36a87d54d14e2b2ea81c1bcef4906ae63 (diff) | |
download | bun-822a00c4d508b54f650933a73ca5f4a3af9a7983.tar.gz bun-822a00c4d508b54f650933a73ca5f4a3af9a7983.tar.zst bun-822a00c4d508b54f650933a73ca5f4a3af9a7983.zip |
Fix a couple important bugs (#4560)bun-v1.0.0
Diffstat (limited to 'src/bun.js/bindings/bindings.cpp')
-rw-r--r-- | src/bun.js/bindings/bindings.cpp | 13 |
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) |