Skip to content

Commit 36ec54b

Browse files
Jichanaddaleax
Jichan
authored andcommitted
src: fix what a dispose without checking
If created platform with CreatePlatform, the crash occurs because it does not check if it was initialized to v8_platform when DisposePlatform was called. Refs: nodejs#31260
1 parent ededfc9 commit 36ec54b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/node_v8_platform-inl.h

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "tracing/node_trace_writer.h"
1313
#include "tracing/trace_event.h"
1414
#include "tracing/traced_value.h"
15+
#include "util.h"
1516

1617
namespace node {
1718

@@ -79,8 +80,15 @@ class NodeTraceStateObserver
7980
};
8081

8182
struct V8Platform {
83+
bool initialize_;
84+
85+
V8Platform()
86+
: initialize_(false) {}
87+
8288
#if NODE_USE_V8_PLATFORM
8389
inline void Initialize(int thread_pool_size) {
90+
CHECK(!initialize_);
91+
initialize_ = true;
8492
tracing_agent_ = std::make_unique<tracing::Agent>();
8593
node::tracing::TraceEventHelper::SetAgent(tracing_agent_.get());
8694
node::tracing::TracingController* controller =
@@ -99,6 +107,10 @@ struct V8Platform {
99107
}
100108

101109
inline void Dispose() {
110+
if(!initialize_)
111+
return;
112+
initialize_ = false;
113+
102114
StopTracingAgent();
103115
platform_->Shutdown();
104116
delete platform_;

0 commit comments

Comments
 (0)