mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
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: https://github.com/nodejs/node/pull/35241 Refs: https://github.com/nodejs/node/pull/31260 Co-authored-by: Anna Henningsen <anna@addaleax.net> PR-URL: https://github.com/nodejs/node/pull/30467 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
1 parent
2f8f76736b
commit
a28c990061
1 file changed
+9
@@ -12,6 +12,7 @@
|
||||
#include "tracing/node_trace_writer.h"
|
||||
#include "tracing/trace_event.h"
|
||||
#include "tracing/traced_value.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace node {
|
||||
|
||||
@@ -79,8 +80,12 @@ class NodeTraceStateObserver
|
||||
};
|
||||
|
||||
struct V8Platform {
|
||||
bool initialized_ = false;
|
||||
|
||||
#if NODE_USE_V8_PLATFORM
|
||||
inline void Initialize(int thread_pool_size) {
|
||||
CHECK(!initialized_);
|
||||
initialized_ = true;
|
||||
tracing_agent_ = std::make_unique<tracing::Agent>();
|
||||
node::tracing::TraceEventHelper::SetAgent(tracing_agent_.get());
|
||||
node::tracing::TracingController* controller =
|
||||
@@ -99,6 +104,10 @@ struct V8Platform {
|
||||
}
|
||||
|
||||
inline void Dispose() {
|
||||
if (!initialized_)
|
||||
return;
|
||||
initialized_ = false;
|
||||
|
||||
StopTracingAgent();
|
||||
platform_->Shutdown();
|
||||
delete platform_;
|
||||
|
||||
Reference in new issue
Block a user