FlushBlockFile(): check for valid FILE pointer

- don't call FileCommit() and fclose() if no valid FILE pointer was
  returned by OpenBlockFile()
This commit is contained in:
Philip Kaufmann 2012-12-01 11:36:53 +01:00
parent cd7fb7d1de
commit b19388dd88

View file

@ -1540,13 +1540,17 @@ void static FlushBlockFile()
posOld.nPos = 0; posOld.nPos = 0;
FILE *fileOld = OpenBlockFile(posOld); FILE *fileOld = OpenBlockFile(posOld);
if (fileOld) {
FileCommit(fileOld); FileCommit(fileOld);
fclose(fileOld); fclose(fileOld);
}
fileOld = OpenUndoFile(posOld); fileOld = OpenUndoFile(posOld);
if (fileOld) {
FileCommit(fileOld); FileCommit(fileOld);
fclose(fileOld); fclose(fileOld);
} }
}
bool FindUndoPos(int nFile, CDiskBlockPos &pos, unsigned int nAddSize); bool FindUndoPos(int nFile, CDiskBlockPos &pos, unsigned int nAddSize);