mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
Avoid leaking file descriptors in RegisterLoad
This is pretty trivial, but if there's an error here we'll leak a file descriptor. Changed it to always close the file.
This commit is contained in:
parent
8b59079b8d
commit
04507de3b7
1 changed files with 4 additions and 3 deletions
|
|
@ -149,13 +149,14 @@ static void RegisterLoad(const string& strInput)
|
||||||
valStr.insert(valStr.size(), buf, bread);
|
valStr.insert(valStr.size(), buf, bread);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ferror(f)) {
|
int error = ferror(f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
string strErr = "Error reading file " + filename;
|
string strErr = "Error reading file " + filename;
|
||||||
throw runtime_error(strErr);
|
throw runtime_error(strErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
// evaluate as JSON buffer register
|
// evaluate as JSON buffer register
|
||||||
RegisterSetJson(key, valStr);
|
RegisterSetJson(key, valStr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue