diff options
author | Gireesh Punathil <gpunathi@in.ibm.com> | 2019-02-05 00:00:05 -0500 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-02-08 14:57:42 +0100 |
commit | c70e85372343ab445676cf2115f65a4e44f97c94 (patch) | |
tree | 06da51ee9ec6cc5c0fd78b3718129fdb84ea72b5 | |
parent | 3a4521a4a2af30bac7f67b5a02b4433a51e9d169 (diff) | |
download | android-node-v8-c70e85372343ab445676cf2115f65a4e44f97c94.tar.gz android-node-v8-c70e85372343ab445676cf2115f65a4e44f97c94.tar.bz2 android-node-v8-c70e85372343ab445676cf2115f65a4e44f97c94.zip |
src: nullcheck on trace controller
Insert a NULLCHECK prior to return. Ideally we do this in the caller,
but the TraceController object is somewhat special as:
1. It is accessed by most threads
2. It's life cycle is managed by Agent::Agent
3. It's getter is invoked through Base Methods (upstream)
Refs: https://github.com/nodejs/node/issues/25814
PR-URL: https://github.com/nodejs/node/pull/25943
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
-rw-r--r-- | src/env.cc | 6 | ||||
-rw-r--r-- | src/node_platform.cc | 1 | ||||
-rw-r--r-- | src/tracing/agent.h | 4 |
3 files changed, 6 insertions, 5 deletions
diff --git a/src/env.cc b/src/env.cc index d099a9e62a..2e0fa251b3 100644 --- a/src/env.cc +++ b/src/env.cc @@ -208,8 +208,7 @@ Environment::Environment(IsolateData* isolate_data, if (tracing::AgentWriterHandle* writer = GetTracingAgentWriter()) { trace_state_observer_ = std::make_unique<TrackingTraceStateObserver>(this); TracingController* tracing_controller = writer->GetTracingController(); - if (tracing_controller != nullptr) - tracing_controller->AddTraceStateObserver(trace_state_observer_.get()); + tracing_controller->AddTraceStateObserver(trace_state_observer_.get()); } destroy_async_id_list_.reserve(512); @@ -272,8 +271,7 @@ Environment::~Environment() { tracing::AgentWriterHandle* writer = GetTracingAgentWriter(); CHECK_NOT_NULL(writer); TracingController* tracing_controller = writer->GetTracingController(); - if (tracing_controller != nullptr) - tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get()); + tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get()); } delete[] heap_statistics_buffer_; diff --git a/src/node_platform.cc b/src/node_platform.cc index b930edb156..139e2ebfc1 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -459,6 +459,7 @@ double NodePlatform::CurrentClockTimeMillis() { } TracingController* NodePlatform::GetTracingController() { + CHECK_NOT_NULL(tracing_controller_); return tracing_controller_; } diff --git a/src/tracing/agent.h b/src/tracing/agent.h index d7d67ce2de..2e95e38582 100644 --- a/src/tracing/agent.h +++ b/src/tracing/agent.h @@ -81,7 +81,9 @@ class Agent { ~Agent(); TracingController* GetTracingController() { - return tracing_controller_.get(); + TracingController* controller = tracing_controller_.get(); + CHECK_NOT_NULL(controller); + return controller; } enum UseDefaultCategoryMode { |