Skip to content

Commit a28c990

Browse files
Jichanaddaleax
Jichan
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. Backport-PR-URL: #35241 Refs: #31260 Co-authored-by: Anna Henningsen <[email protected]> PR-URL: #30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 2f8f767 commit a28c990

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/node_v8_platform-inl.h

+9
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,12 @@ class NodeTraceStateObserver
7980
};
8081

8182
struct V8Platform {
83+
bool initialized_ = false;
84+
8285
#if NODE_USE_V8_PLATFORM
8386
inline void Initialize(int thread_pool_size) {
87+
CHECK(!initialized_);
88+
initialized_ = true;
8489
tracing_agent_ = std::make_unique<tracing::Agent>();
8590
node::tracing::TraceEventHelper::SetAgent(tracing_agent_.get());
8691
node::tracing::TracingController* controller =
@@ -99,6 +104,10 @@ struct V8Platform {
99104
}
100105

101106
inline void Dispose() {
107+
if (!initialized_)
108+
return;
109+
initialized_ = false;
110+
102111
StopTracingAgent();
103112
platform_->Shutdown();
104113
delete platform_;

0 commit comments

Comments
 (0)