From 53911f4e5a5ec50dae73a5d4d36a80637e267fee Mon Sep 17 00:00:00 2001 From: chickenleaf Date: Sat, 26 Oct 2024 21:48:00 +0530 Subject: [PATCH] GC hazard fix in customelementregistry.rs (#34019) * GC hazard fix in customelement.registry.rs Signed-off-by: L Ashwin B * removed redundant borrow Signed-off-by: L Ashwin B --------- Signed-off-by: L Ashwin B --- components/script/dom/customelementregistry.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 2cded8715b3..dfbbe5e5d79 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -598,13 +598,11 @@ impl CustomElementRegistryMethods for CustomElementRegistry { } } - // Step 3 - let mut map = self.when_defined.borrow_mut(); - - // Steps 4, 5 - let promise = map.get(&name).cloned().unwrap_or_else(|| { + // Steps 3, 4, 5 + let existing_promise = self.when_defined.borrow().get(&name).cloned(); + let promise = existing_promise.unwrap_or_else(|| { let promise = Promise::new_in_current_realm(comp, can_gc); - map.insert(name, promise.clone()); + self.when_defined.borrow_mut().insert(name, promise.clone()); promise });