From dc5702a0f24c9bdcf4eded160a7327079dd6edcb Mon Sep 17 00:00:00 2001 From: Martok Date: Wed, 9 Aug 2023 22:41:30 +0200 Subject: [PATCH] Issue #2172 - add null zone sanity checks --- js/src/gc/Marking.cpp | 3 ++- js/src/vm/Runtime.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index 13ec5b0c05..1376df5a4d 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -788,7 +788,8 @@ ShouldMark(GCMarker* gcmarker, JSObject* obj) // Don't mark things outside a zone if we are in a per-zone GC. It is // faster to check our own arena, which we can do since we know that // the object is tenured. - return obj->asTenured().zone()->shouldMarkInZone(); + Zone* zone = obj->asTenured().zone(); + return (zone && zone->shouldMarkInZone()); } template diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index ceb7a498b0..053b7c44b0 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -877,6 +877,9 @@ js::CurrentThreadCanAccessRuntime(const JSRuntime* rt) bool js::CurrentThreadCanAccessZone(Zone* zone) { + if (!zone) + return false; + if (CurrentThreadCanAccessRuntime(zone->runtime_)) return true;