From af63df80b4ae3e7d2126ff1431c06990bab92c4a Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Thu, 16 Nov 2017 15:50:39 +0100 Subject: [PATCH] src: use std::unique_ptr in base-object-inl.h Drive-by fix: delete superflouos nullptr in ptr.reset(). PR-URL: https://github.com/nodejs/node/pull/17079 Reviewed-By: Colin Ihrig Reviewed-By: Timothy Gu --- src/base_object-inl.h | 3 +-- src/env-inl.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/base_object-inl.h b/src/base_object-inl.h index 74c1458b3d69ea..900fc2b3edb9ca 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -65,9 +65,8 @@ inline Environment* BaseObject::env() const { template inline void BaseObject::WeakCallback( const v8::WeakCallbackInfo& data) { - Type* self = data.GetParameter(); + std::unique_ptr self(data.GetParameter()); self->persistent().Reset(); - delete self; } diff --git a/src/env-inl.h b/src/env-inl.h index 4dadf5ea2c1978..c11773ac2e8d1e 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -328,7 +328,7 @@ inline Environment::~Environment() { #if HAVE_INSPECTOR // Destroy inspector agent before erasing the context. The inspector // destructor depends on the context still being accessible. - inspector_agent_.reset(nullptr); + inspector_agent_.reset(); #endif context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,