Skip to content

Commit

Permalink
don't leak file handle
Browse files Browse the repository at this point in the history
  • Loading branch information
akohlmey committed Aug 2, 2024
1 parent a905c9f commit d3919be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/QEQ/fix_qeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,12 @@ void FixQEq::read_file(char *file)
chi[n] = eta[n] = gamma[n] = zeta[n] = zcore[n] = 0.0;
}

FILE *fp = nullptr;
try {
int nlo,nhi;
double val;

FILE *fp = utils::open_potential(file,lmp,nullptr);
fp = utils::open_potential(file,lmp,nullptr);
if (fp == nullptr)
throw qeq_parser_error(fmt::format("Cannot open fix qeq parameter file {}: {}",
file,utils::getsyserror()));
Expand Down Expand Up @@ -798,7 +799,7 @@ void FixQEq::read_file(char *file)
for (int n=nlo; n <= nhi; ++n) setflag[n] = 1;
}
} catch (EOFException &) {
; // catch and ignore to exit loop
fclose(fp);
} catch (std::exception &e) {
error->one(FLERR,e.what());
}
Expand Down

0 comments on commit d3919be

Please sign in to comment.