Skip to content

Commit cf47698

Browse files
jasnellcodebytere
authored andcommitted
src: use BaseObjectPtr in StreamReq::Dispose
Allow the AsyncWrap to be properly detached. Extracted from the [QUIC PR](#32379). Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #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 <anna@addaleax.net>
1 parent 5ff3192 commit cf47698

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/stream_base-inl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
55

66
#include "async_wrap-inl.h"
7+
#include "base_object-inl.h"
78
#include "node.h"
89
#include "stream_base.h"
910
#include "v8.h"
@@ -31,9 +32,10 @@ StreamReq* StreamReq::FromObject(v8::Local<v8::Object> req_wrap_obj) {
3132
}
3233

3334
void StreamReq::Dispose() {
34-
std::unique_ptr<StreamReq> ptr(this);
35+
BaseObjectPtr<AsyncWrap> destroy_me{GetAsyncWrap()};
3536
object()->SetAlignedPointerInInternalField(
3637
StreamReq::kStreamReqField, nullptr);
38+
destroy_me->Detach();
3739
}
3840

3941
v8::Local<v8::Object> StreamReq::object() {

0 commit comments

Comments
 (0)