From 0d9918cd24147c4639bcb98e90efb714a12805d7 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2024 12:26:37 -0500 Subject: [PATCH] fix: dangling raw_ptr NodeBindings::uv_env_ (#42955) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/browser/electron_browser_main_parts.cc | 1 + shell/browser/electron_browser_main_parts.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index b2c0bcb590a8..15cbf89eca6b 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -602,6 +602,7 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() { node_env_->set_trace_sync_io(false); js_env_->DestroyMicrotasksRunner(); node::Stop(node_env_.get(), node::StopFlags::kDoNotTerminateIsolate); + node_bindings_->set_uv_env(nullptr); node_env_.reset(); auto default_context_key = ElectronBrowserContext::PartitionKey("", false); diff --git a/shell/browser/electron_browser_main_parts.h b/shell/browser/electron_browser_main_parts.h index 41d69716f156..fdcfb6c0629a 100644 --- a/shell/browser/electron_browser_main_parts.h +++ b/shell/browser/electron_browser_main_parts.h @@ -155,10 +155,10 @@ class ElectronBrowserMainParts : public content::BrowserMainParts { // Before then, we just exit() without any intermediate steps. std::optional exit_code_; - std::unique_ptr node_bindings_; + const std::unique_ptr node_bindings_; // depends-on: node_bindings_ - std::unique_ptr electron_bindings_; + const std::unique_ptr electron_bindings_; // depends-on: node_bindings_ std::unique_ptr js_env_;