src: always clear wrap before persistent Reset()
In case the handle is stored and accessed after the associated C++ class was destructed, set the internal pointer to nullptr so any getters/setters can return accordingly without aborting the application. PR-URL: https://github.com/nodejs/node/pull/6184 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
ddc19be6de
commit
9dd5b93c42
@ -9,6 +9,7 @@
|
||||
#include "req-wrap-inl.h"
|
||||
#include "tree.h"
|
||||
#include "util.h"
|
||||
#include "util-inl.h"
|
||||
#include "uv.h"
|
||||
|
||||
#include <errno.h>
|
||||
@ -258,6 +259,7 @@ class QueryWrap : public AsyncWrap {
|
||||
|
||||
virtual ~QueryWrap() override {
|
||||
CHECK_EQ(false, persistent().IsEmpty());
|
||||
ClearWrap(object());
|
||||
persistent().Reset();
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ void HandleWrap::OnClose(uv_handle_t* handle) {
|
||||
if (have_close_callback)
|
||||
wrap->MakeCallback(env->onclose_string(), 0, nullptr);
|
||||
|
||||
wrap->object()->SetAlignedPointerInInternalField(0, nullptr);
|
||||
ClearWrap(wrap->object());
|
||||
wrap->persistent().Reset();
|
||||
delete wrap;
|
||||
}
|
||||
|
@ -5023,6 +5023,7 @@ class PBKDF2Request : public AsyncWrap {
|
||||
|
||||
~PBKDF2Request() override {
|
||||
release();
|
||||
ClearWrap(object());
|
||||
persistent().Reset();
|
||||
}
|
||||
|
||||
@ -5288,6 +5289,7 @@ class RandomBytesRequest : public AsyncWrap {
|
||||
}
|
||||
|
||||
~RandomBytesRequest() override {
|
||||
ClearWrap(object());
|
||||
persistent().Reset();
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ template <typename T>
|
||||
ReqWrap<T>::~ReqWrap() {
|
||||
CHECK_EQ(req_.data, this); // Assert that someone has called Dispatched().
|
||||
CHECK_EQ(false, persistent().IsEmpty());
|
||||
ClearWrap(object());
|
||||
persistent().Reset();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user