aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-27 06:17:32 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-27 06:17:32 -0800
commitfaad2505599048e0b6ce9aa84f7ff334b45e25db (patch)
treee538898be7ec36fe43be6fc86751f8b228d10da2
parent74e87b5a8a94a59bbfa32bba554503921c74c68c (diff)
downloadbun-faad2505599048e0b6ce9aa84f7ff334b45e25db.tar.gz
bun-faad2505599048e0b6ce9aa84f7ff334b45e25db.tar.zst
bun-faad2505599048e0b6ce9aa84f7ff334b45e25db.zip
Fix crash in Headers.prototype.count
-rw-r--r--src/bun.js/bindings/webcore/JSFetchHeaders.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bun.js/bindings/webcore/JSFetchHeaders.cpp b/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
index af4d68fe7..2c83778a2 100644
--- a/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
+++ b/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
@@ -172,7 +172,10 @@ template<> void JSFetchHeadersDOMConstructor::initializeProperties(VM& vm, JSDOM
JSC_DEFINE_CUSTOM_GETTER(jsFetchHeadersGetterCount, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
{
auto& vm = JSC::getVM(globalObject);
- JSFetchHeaders* castedThis = jsCast<JSFetchHeaders*>(JSValue::decode(thisValue));
+ JSFetchHeaders* castedThis = jsDynamicCast<JSFetchHeaders*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!castedThis)) {
+ return JSValue::encode(jsUndefined());
+ }
auto& impl = castedThis->wrapped();
auto count = impl.size();
@@ -193,7 +196,7 @@ static const HashTableValue JSFetchHeadersPrototypeTableValues[] = {
{ "values"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_values, 0 } },
{ "forEach"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_forEach, 1 } },
{ "toJSON"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_toJSON, 0 } },
- { "count"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), NoIntrinsic, { HashTableValue::GetterSetterType, jsFetchHeadersGetterCount, 0 } },
+ { "count"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum), NoIntrinsic, { HashTableValue::GetterSetterType, jsFetchHeadersGetterCount, 0 } },
};
const ClassInfo JSFetchHeadersPrototype::s_info = { "Headers"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchHeadersPrototype) };