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 <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This commit is contained in:
Franziska Hinkelmann 2017-11-16 15:50:39 +01:00
parent ce6c7f5b01
commit f841fc63dd
2 changed files with 2 additions and 3 deletions

View File

@ -65,9 +65,8 @@ inline Environment* BaseObject::env() const {
template <typename Type> template <typename Type>
inline void BaseObject::WeakCallback( inline void BaseObject::WeakCallback(
const v8::WeakCallbackInfo<Type>& data) { const v8::WeakCallbackInfo<Type>& data) {
Type* self = data.GetParameter(); std::unique_ptr<Type> self(data.GetParameter());
self->persistent().Reset(); self->persistent().Reset();
delete self;
} }

View File

@ -329,7 +329,7 @@ inline Environment::~Environment() {
#if HAVE_INSPECTOR #if HAVE_INSPECTOR
// Destroy inspector agent before erasing the context. The inspector // Destroy inspector agent before erasing the context. The inspector
// destructor depends on the context still being accessible. // destructor depends on the context still being accessible.
inspector_agent_.reset(nullptr); inspector_agent_.reset();
#endif #endif
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex, context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,