From cf476984f652705e0d9c181f5f1d416eb1701e61 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 27 Apr 2020 13:01:13 -0700 Subject: [PATCH] src: use BaseObjectPtr in StreamReq::Dispose Allow the AsyncWrap to be properly detached. Extracted from the [QUIC PR](https://github.com/nodejs/node/pull/32379). Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/33102 Refs: https://github.com/nodejs/node/pull/32379/files?file-filters%5B%5D=.bat&file-filters%5B%5D=.gyp&file-filters%5B%5D=.gypi&file-filters%5B%5D=.h&file-filters%5B%5D=.md&file-filters%5B%5D=.py&file-filters%5B%5D=.sh&file-filters%5B%5D=No+extension&file-filters%5B%5D=dotfile#r409084763 Reviewed-By: Anna Henningsen --- src/stream_base-inl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index 95152e34915853..9660cc386cef82 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -4,6 +4,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "async_wrap-inl.h" +#include "base_object-inl.h" #include "node.h" #include "stream_base.h" #include "v8.h" @@ -31,9 +32,10 @@ StreamReq* StreamReq::FromObject(v8::Local req_wrap_obj) { } void StreamReq::Dispose() { - std::unique_ptr ptr(this); + BaseObjectPtr destroy_me{GetAsyncWrap()}; object()->SetAlignedPointerInInternalField( StreamReq::kStreamReqField, nullptr); + destroy_me->Detach(); } v8::Local StreamReq::object() {