Fixed accidental casting of a NULL pointer in msr2data---originally this was expected to lead to an exception (but obviously things are different)

This commit is contained in:
Bastian M. Wojek
2011-02-21 20:44:06 +00:00
parent 076753e018
commit c048dc4553
2 changed files with 24 additions and 21 deletions

View File

@ -1304,15 +1304,16 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const string &msrOu
// and do the fitting
// check if MUSRFITPATH is set, if not issue a warning
string path;
try {
path = boost::lexical_cast<string>(getenv("MUSRFITPATH"));
path.append("/");
}
catch(boost::bad_lexical_cast &) {
string path("");
char *pathPtr(getenv("MUSRFITPATH"));
if (pathPtr) {
path = boost::lexical_cast<string>(pathPtr);
if (!path.empty()) {
path.append("/");
}
} else {
cerr << endl << ">> msr2data: **WARNING** The MUSRFITPATH environment variable is not set!";
cerr << endl << ">> msr2data: **WARNING** Please set it or at least ensure that musrfit can be found on the PATH!" << endl;
path = "";
}
ostringstream oss;
oss << path << "musrfit" << " " << *fRunVectorIter << "-OneRunFit" << fFileExtension << ".msr";

View File

@ -689,15 +689,16 @@ int main(int argc, char *argv[])
// and do the fitting
if (!onlyInputCreation) {
// check if MUSRFITPATH is set, if not issue a warning
string path;
try {
path = boost::lexical_cast<string>(getenv("MUSRFITPATH"));
path.append("/");
}
catch(boost::bad_lexical_cast &) {
string path("");
char *pathPtr(getenv("MUSRFITPATH"));
if (pathPtr) {
path = boost::lexical_cast<string>(pathPtr);
if (!path.empty()) {
path.append("/");
}
} else {
cerr << endl << ">> msr2data: **WARNING** The MUSRFITPATH environment variable is not set!";
cerr << endl << ">> msr2data: **WARNING** Please set it or at least ensure that musrfit can be found on the PATH!" << endl;
path = "";
}
ostringstream oss;
oss << path << "musrfit" << " " << strInfile.str() << " " << musrfitOptions;
@ -774,15 +775,16 @@ int main(int argc, char *argv[])
// and do the fitting
if (!onlyInputCreation) {
// check if MUSRFITPATH is set, if not issue a warning
string path;
try {
path = boost::lexical_cast<string>(getenv("MUSRFITPATH"));
path.append("/");
}
catch(boost::bad_lexical_cast &) {
string path("");
char *pathPtr(getenv("MUSRFITPATH"));
if (pathPtr) {
path = boost::lexical_cast<string>(pathPtr);
if (!path.empty()) {
path.append("/");
}
} else {
cerr << endl << ">> msr2data: **WARNING** The MUSRFITPATH environment variable is not set!";
cerr << endl << ">> msr2data: **WARNING** Please set it or at least ensure that musrfit can be found on the PATH!" << endl;
path = "";
}
ostringstream oss;
oss << path << "musrfit" << " " << strInfile.str() << " " << musrfitOptions;