added paranoia pointer checks.
All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 17s

This commit is contained in:
2025-11-12 08:09:03 +01:00
parent 9363bafec4
commit 22112e47b2

View File

@@ -518,6 +518,7 @@ int main(int argc, char *argv[])
}
}
memset(filename, '\0', sizeof(filename));
strcpy(filename, "");
for (int i=1; i<argc; i++) {
if (strstr(argv[i], ".msr")) {
@@ -645,7 +646,8 @@ int main(int argc, char *argv[])
std::cerr << std::endl << ">> musrfit **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
std::cerr << std::endl;
} else {
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
memset(startup_path_name, '\0', sizeof(startup_path_name));
strncpy(startup_path_name, startupHandler->GetStartupFilePath().Data(), sizeof(startup_path_name));
saxParser->ConnectToHandler("PStartupHandler", startupHandler.get());
//status = saxParser->ParseFile(startup_path_name);
// parsing the file as above seems to lead to problems in certain environments;
@@ -696,15 +698,35 @@ int main(int argc, char *argv[])
bool success = dataHandler->IsAllDataAvailable();
if (!success) {
std::cout << std::endl << ">> musrfit **ERROR** Couldn't read all data files, will quit ..." << std::endl;
std::cerr << std::endl << ">> musrfit **ERROR** Couldn't read all data files, will quit ..." << std::endl;
}
// if present, replace the run title of the <msr-file> with the run title of the FIRST run in the run block of the msr-file
if (title_from_data_file && success) {
PMsrRunList *rl = msrHandler->GetMsrRunList();
PRawRunData *rrd = dataHandler->GetRunData(*(rl->at(0).GetRunName()));
if (rrd->GetRunTitle()->Length() > 0)
msrHandler->SetMsrTitle(*rrd->GetRunTitle());
if (rl->empty()) {
success = false;
std::cerr << std::endl << ">> musrfit **ERROR** no run list present." << std::endl;
}
if (success) {
TString *name = rl->at(0).GetRunName();
if (name == nullptr) {
std::cerr << std::endl << ">> musrfit **ERROR** to obtain run list name." << std::endl;
success = false;
}
PRawRunData *rrd = nullptr;
if (success) {
rrd = dataHandler->GetRunData(*(rl->at(0).GetRunName()));
if (rrd == nullptr) {
std::cerr << std::endl << ">> musrfit **ERROR** no raw run data avaliable." << std::endl;
success = false;
}
}
if (success) {
if (rrd->GetRunTitle()->Length() > 0)
msrHandler->SetMsrTitle(*rrd->GetRunTitle());
}
}
}
// generate the necessary fit histogramms for the fit
@@ -725,7 +747,7 @@ int main(int argc, char *argv[])
// start timeout thread
std::unique_ptr<TThread> th;
if (timeout_enabled) {
pid_t musrfit_pid = getpid();
static pid_t musrfit_pid = getpid();
th = std::make_unique<TThread>(musrfit_timeout, (void*)&musrfit_pid);
if (th) {
th->Run();
@@ -813,6 +835,10 @@ int main(int argc, char *argv[])
}
}
if (th && timeout_enabled) {
th->Kill();
}
std::cout << std::endl << "done ..." << std::endl;
return PMUSR_SUCCESS;