Fixed a segfault caused by an unprotected call to getenv()

This commit is contained in:
Ray Speth 2012-01-09 17:31:04 +00:00
parent 060f0b6268
commit 0b9d912239

View file

@ -61,14 +61,19 @@ namespace ctml {
static string pypath() {
string s = "python";
const char* py = getenv("PYTHON_CMD");
// Try to source the "setup_cantera" script from the user's home
// directory in order to set PYTHON_CMD.
if (!py) {
const char* hm = getenv("HOME");
string home = stripws(string(hm));
string cmd = string(". ")+home
+string("/setup_cantera &> /dev/null");
if (hm) {
string home = stripws(string(hm));
string cmd = string(". ") + home
+string("/setup_cantera &> /dev/null");
system(cmd.c_str());
}
py = getenv("PYTHON_CMD");
}
}
if (py) {
string sp = stripws(string(py));
if (sp.size() > 0) {