Skip to content

Commit c07d127

Browse files
committed
src: turn inspector raw pointer into unique_ptr
Use a unique pointer to make ownership clear. PR-URL: #16974 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]>
1 parent 8101042 commit c07d127

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/env-inl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,9 @@ inline Environment::~Environment() {
326326
v8::HandleScope handle_scope(isolate());
327327

328328
#if HAVE_INSPECTOR
329-
// Destroy inspector agent before erasing the context.
330-
delete inspector_agent_;
329+
// Destroy inspector agent before erasing the context. The inspector
330+
// destructor depends on the context still being accessible.
331+
inspector_agent_.reset(nullptr);
331332
#endif
332333

333334
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,

src/env.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ class Environment {
689689

690690
#if HAVE_INSPECTOR
691691
inline inspector::Agent* inspector_agent() const {
692-
return inspector_agent_;
692+
return inspector_agent_.get();
693693
}
694694
#endif
695695

@@ -734,7 +734,7 @@ class Environment {
734734
std::map<std::string, uint64_t> performance_marks_;
735735

736736
#if HAVE_INSPECTOR
737-
inspector::Agent* const inspector_agent_;
737+
std::unique_ptr<inspector::Agent> inspector_agent_;
738738
#endif
739739

740740
HandleWrapQueue handle_wrap_queue_;

0 commit comments

Comments
 (0)