From 5d4634a62448e2dd0a0f12ba47bf2afcfc3834e1 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sat, 8 Jul 2023 22:33:29 -0400 Subject: [PATCH] exceptionhandler.cpp: Fix possible crash if popen fails Co-Authored-By: etbe <14937006+etbe@users.noreply.github.com> --- lib/exceptionhandler/exceptionhandler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/exceptionhandler/exceptionhandler.cpp b/lib/exceptionhandler/exceptionhandler.cpp index 40e2a46e11a..1b3e794f528 100644 --- a/lib/exceptionhandler/exceptionhandler.cpp +++ b/lib/exceptionhandler/exceptionhandler.cpp @@ -730,6 +730,11 @@ static bool fetchProgramPath(char *const output_programPath, size_t const bufSiz * output in output_programPath. */ whichProgramStream = popen(whichProgramCommand, "r"); + if(!whichProgramStream) + { + debug(LOG_WARNING, "failed to popen which"); + return false; + } bytesRead = fread(output_programPath, 1, bufSize, whichProgramStream); pclose(whichProgramStream);