Browse Source

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

0.15
kirit93 8 years ago
parent
commit
40f11f8872
  1. 15
      src/util.cpp

15
src/util.cpp

@ -214,12 +214,13 @@ void OpenDebugLog() @@ -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) @@ -838,4 +839,4 @@ std::string CopyrightHolders(const std::string& strPrefix)
strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
}
return strCopyrightHolders;
}
}
Loading…
Cancel
Save