don't leak file handle
This commit is contained in:
@ -763,11 +763,12 @@ void FixQEq::read_file(char *file)
|
|||||||
chi[n] = eta[n] = gamma[n] = zeta[n] = zcore[n] = 0.0;
|
chi[n] = eta[n] = gamma[n] = zeta[n] = zcore[n] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE *fp = nullptr;
|
||||||
try {
|
try {
|
||||||
int nlo,nhi;
|
int nlo,nhi;
|
||||||
double val;
|
double val;
|
||||||
|
|
||||||
FILE *fp = utils::open_potential(file,lmp,nullptr);
|
fp = utils::open_potential(file,lmp,nullptr);
|
||||||
if (fp == nullptr)
|
if (fp == nullptr)
|
||||||
throw qeq_parser_error(fmt::format("Cannot open fix qeq parameter file {}: {}",
|
throw qeq_parser_error(fmt::format("Cannot open fix qeq parameter file {}: {}",
|
||||||
file,utils::getsyserror()));
|
file,utils::getsyserror()));
|
||||||
@ -798,7 +799,7 @@ void FixQEq::read_file(char *file)
|
|||||||
for (int n=nlo; n <= nhi; ++n) setflag[n] = 1;
|
for (int n=nlo; n <= nhi; ++n) setflag[n] = 1;
|
||||||
}
|
}
|
||||||
} catch (EOFException &) {
|
} catch (EOFException &) {
|
||||||
; // catch and ignore to exit loop
|
fclose(fp);
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
error->one(FLERR,e.what());
|
error->one(FLERR,e.what());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user