Fix for issue #9775. Added check for open() returning a NULL pointer.

Github-Pull: #9798
Rebased-From: 40f11f8872
This commit is contained in:
kirit93 2017-02-19 12:05:02 +05:30 committed by Wladimir J. van der Laan
parent ae1c4e24a6
commit e22c0671c7
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
1 changed files with 8 additions and 7 deletions

View File

@ -214,12 +214,13 @@ void OpenDebugLog()
assert(vMsgsBeforeOpenLog);
boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
fileout = fopen(pathDebug.string().c_str(), "a");
if (fileout) setbuf(fileout, NULL); // unbuffered
// dump buffered messages from before we opened the log
while (!vMsgsBeforeOpenLog->empty()) {
FileWriteStr(vMsgsBeforeOpenLog->front(), fileout);
vMsgsBeforeOpenLog->pop_front();
if (fileout) {
setbuf(fileout, NULL); // unbuffered
// dump buffered messages from before we opened the log
while (!vMsgsBeforeOpenLog->empty()) {
FileWriteStr(vMsgsBeforeOpenLog->front(), fileout);
vMsgsBeforeOpenLog->pop_front();
}
}
delete vMsgsBeforeOpenLog;
@ -838,4 +839,4 @@ std::string CopyrightHolders(const std::string& strPrefix)
strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
}
return strCopyrightHolders;
}
}