From 0564b790e7c8dd80ff8ec89bfc6a0f2c09ea25d2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Mar 2019 10:57:05 +0100 Subject: [PATCH] Take into account that PATH could be empty --- src/tests/common-files/gnuplot_i.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tests/common-files/gnuplot_i.h b/src/tests/common-files/gnuplot_i.h index afdc47c3a..5f825b8b5 100644 --- a/src/tests/common-files/gnuplot_i.h +++ b/src/tests/common-files/gnuplot_i.h @@ -2082,10 +2082,13 @@ bool Gnuplot::get_program_path() // Retrieves a C string containing the value of environment variable PATH path = std::getenv("PATH"); std::stringstream s; - s << path; - if (s.fail()) + if (!path) { - throw GnuplotException("Path is not set"); + s << path; + } + if (s.fail() or s.gcount() == 0) + { + throw GnuplotException("PATH is not set"); } std::string path_str = s.str();