Skip to content

Commit e67df04

Browse files
jasnellcodebytere
authored andcommittedJun 9, 2020
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 98a7026 commit e67df04

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎src/stream_base-inl.h

+3-1
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"
@@ -36,9 +37,10 @@ inline StreamReq* StreamReq::FromObject(v8::Local<v8::Object> req_wrap_obj) {
3637
}
3738

3839
inline void StreamReq::Dispose() {
40+
BaseObjectPtr<AsyncWrap> destroy_me{GetAsyncWrap()};
3941
object()->SetAlignedPointerInInternalField(
4042
StreamReq::kStreamReqField, nullptr);
41-
delete this;
43+
destroy_me->Detach();
4244
}
4345

4446
inline v8::Local<v8::Object> StreamReq::object() {

0 commit comments

Comments
 (0)
Please sign in to comment.