From d610f4ca434ec7a1403700bffa26f1a710afc164 Mon Sep 17 00:00:00 2001 From: john30 Date: Tue, 26 Dec 2017 14:15:35 +0100 Subject: [PATCH] check null in signal handler --- src/ebusd/main.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index e9bc829e..91d5ea72 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -650,11 +650,11 @@ void closePidFile() { */ void shutdown() { // stop main loop and all dependent components - if (s_mainLoop != NULL) { + if (s_mainLoop) { delete s_mainLoop; s_mainLoop = NULL; } - if (s_messageMap != NULL) { + if (s_messageMap) { delete s_messageMap; s_messageMap = NULL; } @@ -695,11 +695,19 @@ void signalHandler(int sig) { break; case SIGINT: logNotice(lf_main, "SIGINT received"); - s_mainLoop->shutdown(); + if (s_mainLoop) { + s_mainLoop->shutdown(); + } else { + shutdown(); + } break; case SIGTERM: logNotice(lf_main, "SIGTERM received"); - s_mainLoop->shutdown(); + if (s_mainLoop) { + s_mainLoop->shutdown(); + } else { + shutdown(); + } break; default: logNotice(lf_main, "undefined signal %s", strsignal(sig));