Merge pull request #6488

17ac0f4 Avoid leaking file descriptors in RegisterLoad (Casey Rodarmor)
This commit is contained in:
Wladimir J. van der Laan 2015-07-29 18:58:54 +02:00
commit 7cbed7fa28
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
1 changed files with 4 additions and 3 deletions

View File

@ -143,13 +143,14 @@ static void RegisterLoad(const string& strInput)
valStr.insert(valStr.size(), buf, bread);
}
if (ferror(f)) {
int error = ferror(f);
fclose(f);
if (error) {
string strErr = "Error reading file " + filename;
throw runtime_error(strErr);
}
fclose(f);
// evaluate as JSON buffer register
RegisterSetJson(key, valStr);
}