Skip to content

Commit 71181b9

Browse files
fhinkelevanlucas
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 8658f26 commit 71181b9

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

356356
#if HAVE_INSPECTOR
357-
// Destroy inspector agent before erasing the context.
358-
delete inspector_agent_;
357+
// Destroy inspector agent before erasing the context. The inspector
358+
// destructor depends on the context still being accessible.
359+
inspector_agent_.reset(nullptr);
359360
#endif
360361

361362
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,

src/env.h

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

671671
#if HAVE_INSPECTOR
672672
inline inspector::Agent* inspector_agent() const {
673-
return inspector_agent_;
673+
return inspector_agent_.get();
674674
}
675675
#endif
676676

@@ -715,7 +715,7 @@ class Environment {
715715
std::map<std::string, uint64_t> performance_marks_;
716716

717717
#if HAVE_INSPECTOR
718-
inspector::Agent* const inspector_agent_;
718+
std::unique_ptr<inspector::Agent> inspector_agent_;
719719
#endif
720720

721721
HandleWrapQueue handle_wrap_queue_;

0 commit comments

Comments
 (0)