From 60a3df7abc76c95a558c072eabb29aaa026b7f9f Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 2 Jan 2016 10:57:21 +0100 Subject: [PATCH] CShellWindow: do not dereference NULL pointers additionally, try to shorten the debug messages slightly and make the output more useful in the error case for my_popen() Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/0b8365f908931605fdfb0dbc2c83e025de2f46d1 Author: Stefan Seyfried Date: 2016-01-02 (Sat, 02 Jan 2016) ------------------ This commit was generated by Migit --- src/gui/widget/shellwindow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index da1f1ed53..308ceaa8d 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -80,7 +80,7 @@ void CShellWindow::exec() if (!f) { if (res) *res = -1; - dprintf(DEBUG_NORMAL, "[CShellWindow] [%s - %d] Error! my_popen returns: %d command: %s\n", __func__, __LINE__, *res, cmd.c_str()); + dprintf(DEBUG_NORMAL, "[CShellWindow] [%s:%d] Error! my_popen errno: %d command: %s\n", __func__, __LINE__, errno, cmd.c_str()); return; } @@ -159,7 +159,10 @@ void CShellWindow::exec() //callback for line handler std::string s_output = std::string((output)); OnShellOutputLoop(&s_output, res, &ok); - dprintf(DEBUG_NORMAL, "[CShellWindow] [%s - %d] res=%d ok=%d\n", __func__, __LINE__, *res, ok); + if (res) + dprintf(DEBUG_NORMAL, "[CShellWindow] [%s:%d] res=%d ok=%d\n", __func__, __LINE__, *res, ok); + else + dprintf(DEBUG_NORMAL, "[CShellWindow] [%s:%d] res=NULL ok=%d\n", __func__, __LINE__, ok); if (lines.size() > lines_max) lines.pop_front();