From 2b8cd9a01be7a35010426b8ea8b566c1b2bd89b1 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 1 Nov 2019 14:41:18 -0700 Subject: [PATCH] Nullptr check --- src/core/lib/iomgr/exec_ctx.cc | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index 15521267836..9a5ad6eee0a 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -176,24 +176,28 @@ grpc_millis ExecCtx::Now() { void ExecCtx::Run(const DebugLocation& location, grpc_closure* closure, grpc_error* error) { + if (closure != nullptr) { #ifndef NDEBUG - if (closure->scheduled) { - gpr_log(GPR_ERROR, - "Closure already scheduled. (closure: %p, created: [%s:%d], " - "previously scheduled at: [%s: %d], newly scheduled at [%s: %d], " - "run?: %s", - closure, closure->file_created, closure->line_created, - closure->file_initiated, closure->line_initiated, location.file(), - location.line(), closure->run ? "true" : "false"); - abort(); - } - closure->scheduled = true; - closure->file_initiated = location.file(); - closure->line_initiated = location.line(); - closure->run = false; - GPR_ASSERT(closure->cb != nullptr); + if (closure->scheduled) { + gpr_log(GPR_ERROR, + "Closure already scheduled. (closure: %p, created: [%s:%d], " + "previously scheduled at: [%s: %d], newly scheduled at [%s: %d], " + "run?: %s", + closure, closure->file_created, closure->line_created, + closure->file_initiated, closure->line_initiated, location.file(), + location.line(), closure->run ? "true" : "false"); + abort(); + } + closure->scheduled = true; + closure->file_initiated = location.file(); + closure->line_initiated = location.line(); + closure->run = false; + GPR_ASSERT(closure->cb != nullptr); #endif - exec_ctx_sched(closure, error); + exec_ctx_sched(closure, error); + } else { + GRPC_ERROR_UNREF(error); + } } } // namespace grpc_core