From 7673da383212641a8af3415250cb6285a83bee20 Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Mon, 23 Nov 2020 16:16:14 -0600 Subject: [PATCH] smell: throwing heap object null check. --- simgear/debug/OsgIoCapture.hxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/simgear/debug/OsgIoCapture.hxx b/simgear/debug/OsgIoCapture.hxx index 611778fa..5a7c990d 100644 --- a/simgear/debug/OsgIoCapture.hxx +++ b/simgear/debug/OsgIoCapture.hxx @@ -22,19 +22,21 @@ public: // as this is going to segfault ignore the translation of severity and always output the message. SG_LOG(SG_GL, SG_ALERT, message); #ifndef DEBUG - throw new std::string(message); + throw std::string(message); //int* trigger_segfault = 0; //*trigger_segfault = 0; #endif return; } char*tmessage = strdup(message); - char*lf = strrchr(tmessage, '\n'); - if (lf) - *lf = 0; + if (tmessage) { + char*lf = strrchr(tmessage, '\n'); + if (lf) + *lf = 0; - SG_LOG(SG_OSG, translateSeverity(severity), tmessage); - free(tmessage); + SG_LOG(SG_OSG, translateSeverity(severity), tmessage); + free(tmessage); + } } private: