From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- js/src/gc/GCAPI.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'js/src/gc/GCAPI.cpp') diff --git a/js/src/gc/GCAPI.cpp b/js/src/gc/GCAPI.cpp index ab6c3c297a..293bfce80d 100644 --- a/js/src/gc/GCAPI.cpp +++ b/js/src/gc/GCAPI.cpp @@ -817,11 +817,17 @@ JS_PUBLIC_API void js::gc::SetPerformanceHint(JSContext* cx, AutoSelectGCHeap::AutoSelectGCHeap(JSContext* cx, size_t allowedNurseryCollections) : cx_(cx), allowedNurseryCollections_(allowedNurseryCollections) { - JS::AddGCNurseryCollectionCallback(cx, &NurseryCollectionCallback, this); + if (!JS::AddGCNurseryCollectionCallback(cx, &NurseryCollectionCallback, + this)) { + cx_ = nullptr; + } } AutoSelectGCHeap::~AutoSelectGCHeap() { - JS::RemoveGCNurseryCollectionCallback(cx_, &NurseryCollectionCallback, this); + if (cx_) { + JS::RemoveGCNurseryCollectionCallback(cx_, &NurseryCollectionCallback, + this); + } } /* static */ -- cgit v1.2.3