Skip to content

Commit

Permalink
Add nullptr protection
Browse files Browse the repository at this point in the history
  • Loading branch information
fuhlig1 committed Jun 23, 2023
1 parent 66317ac commit 6edadf8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions examples/simulation/Tutorial2/macros/compare_seed_value.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ int compare_seed_value(TString filename, UInt_t initial_seed) {
// transport run

std::unique_ptr<TFile> myFile( TFile::Open(filename) );
if (!myFile || myFile->IsZombie()) {
std::cerr << "Error opening file " << filename << std::endl;
return 1;
}

std::unique_ptr<FairBaseParSet> par(myFile->Get<FairBaseParSet>("FairBaseParSet"));
if (!par) {
std::cerr << "Did not find FairBaseParSet in input file" << std::endl;
return 1;
}

UInt_t seed = par->GetRndSeed();

if ( seed == initial_seed ) {
Expand All @@ -34,7 +44,3 @@ int compare_seed_value(TString filename, UInt_t initial_seed) {
return 1;
}
}

int main() {
return compare_seed_value("",1);
}

0 comments on commit 6edadf8

Please sign in to comment.