Skip to content

Commit b1802ed

Browse files
fhinkelgibfahn
authored andcommitted
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 ad331f2 commit b1802ed

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
@@ -347,8 +347,9 @@ inline Environment::~Environment() {
347347
v8::HandleScope handle_scope(isolate());
348348

349349
#if HAVE_INSPECTOR
350-
// Destroy inspector agent before erasing the context.
351-
delete inspector_agent_;
350+
// Destroy inspector agent before erasing the context. The inspector
351+
// destructor depends on the context still being accessible.
352+
inspector_agent_.reset(nullptr);
352353
#endif
353354

354355
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,

src/env.h

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

674674
#if HAVE_INSPECTOR
675675
inline inspector::Agent* inspector_agent() const {
676-
return inspector_agent_;
676+
return inspector_agent_.get();
677677
}
678678
#endif
679679

@@ -718,7 +718,7 @@ class Environment {
718718
std::map<std::string, uint64_t> performance_marks_;
719719

720720
#if HAVE_INSPECTOR
721-
inspector::Agent* const inspector_agent_;
721+
std::unique_ptr<inspector::Agent> inspector_agent_;
722722
#endif
723723

724724
HandleWrapQueue handle_wrap_queue_;

0 commit comments

Comments
 (0)