From 2a875c3c6ffd5e7023d22990a4ba8e90c4cc1307 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 26 Jun 2018 10:16:20 -0400 Subject: [PATCH] src: add null check to GetCategoryGroupEnabled() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The input to this function shouldn't be null, and callers are not equipped to deal with a nullptr return value. Change the nullptr return to a CHECK_NOT_NULL(). Also fix the indentation of the function. PR-URL: https://github.com/nodejs/node/pull/21545 Fixes: https://github.com/nodejs/node/issues/19991 Reviewed-By: Wyatt Preul Reviewed-By: Anna Henningsen Reviewed-By: Daniel Bevenius Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen --- src/node_trace_events.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index 13a3dbce1b26b8..985c706dc4a2f1 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -95,9 +95,8 @@ static std::unordered_set categoryGroups; // Gets a pointer to the category-enabled flags for a tracing category group, // if tracing is enabled for it. static const uint8_t* GetCategoryGroupEnabled(const char* category_group) { - if (category_group == nullptr) return nullptr; - - return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); + CHECK_NOT_NULL(category_group); + return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); } static const char* GetCategoryGroup(Environment* env,