Skip to content

Commit 9cbb9a8

Browse files
author
Ralph Küpper
committed
fix(runtime): js_object_has_property must reject handle-band receivers
`key in <handle>` where the receiver is a Web Fetch Headers/Request/Response handle (a fetch-band registry id, e.g. 0x40007) dereferenced the id as a heap object -> EXC_BAD_ACCESS. Return false for handle-band receivers instead, same family as the string_from_header / inline-.length / json_stringify guards.
1 parent 43f212e commit 9cbb9a8

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

crates/perry-runtime/src/object/field_get_set.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,19 @@ pub extern "C" fn js_object_has_property(obj: f64, key: f64) -> f64 {
22632263
};
22642264
}
22652265

2266+
// A handle-band value (Web Fetch Headers/Request/Response, net/http handles,
2267+
// zlib streams) is a registry id, not a heap object — the pointer paths below
2268+
// would dereference the id and segfault. `key in <handle>` has no own-property
2269+
// meaning for these registry handles, so report `false` instead of crashing.
2270+
// Same handle-band family as the string_from_header / inline-`.length` guards.
2271+
if obj_val.is_pointer()
2272+
&& crate::value::addr_class::is_handle_band(
2273+
(obj_val.bits() & crate::value::POINTER_MASK) as usize,
2274+
)
2275+
{
2276+
return nanbox_false;
2277+
}
2278+
22662279
// #1758: a SYMBOL key. The class-ref path below + the keys_array scan
22672280
// (string keys only) can't see a class-object's static `[Sym]` props nor
22682281
// ones inherited from a class-expression parent. Delegate to the symbol

0 commit comments

Comments
 (0)