Lib: check return value

This does not break compatibility because the current caller CLIENT_STATE::write_state_file() is opening the file again for each retry if MFILE::close() fails.
fixes CID 34502 found by Coverity
This commit is contained in:
Christian Beer 2015-11-04 14:44:45 +01:00
parent 317460e4f8
commit 4654bdc234
1 changed files with 4 additions and 1 deletions

View File

@ -148,10 +148,13 @@ int MFILE::puts(const char* p) {
return n;
}
// This is closing the file even if it couldn't flush it.
// The caller needs to check the return value and open the file again before the next retry.
//
int MFILE::close() {
int retval = 0;
if (f) {
flush();
retval = flush();
fclose(f);
f = NULL;
}