From f3ba11c0453de61b662efff6e9d0bd4ce8798257 Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Sun, 12 Nov 2017 19:52:13 +0100 Subject: [PATCH] src: turn inspector raw pointer into unique_ptr Use a unique pointer to make ownership clear. --- src/env-inl.h | 5 +++-- src/env.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index 5c28b2334bd661..4dadf5ea2c1978 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -326,8 +326,9 @@ inline Environment::~Environment() { v8::HandleScope handle_scope(isolate()); #if HAVE_INSPECTOR - // Destroy inspector agent before erasing the context. - delete inspector_agent_; + // Destroy inspector agent before erasing the context. The inspector + // destructor depends on the context still being accessible. + inspector_agent_.reset(nullptr); #endif context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex, diff --git a/src/env.h b/src/env.h index 296fcf4877baba..e37dcf17aeb1d6 100644 --- a/src/env.h +++ b/src/env.h @@ -689,7 +689,7 @@ class Environment { #if HAVE_INSPECTOR inline inspector::Agent* inspector_agent() const { - return inspector_agent_; + return inspector_agent_.get(); } #endif @@ -734,7 +734,7 @@ class Environment { std::map performance_marks_; #if HAVE_INSPECTOR - inspector::Agent* const inspector_agent_; + std::unique_ptr inspector_agent_; #endif HandleWrapQueue handle_wrap_queue_;