diff options
| author | kirit93 <[email protected]> | 2017-02-19 12:05:02 +0530 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-02-21 14:33:34 +0100 |
| commit | e22c0671c74bc4db70b3ba04d093cd110f9f22a7 (patch) | |
| tree | 69debe38dc94d31db7998c57847b1423d621c689 /src/util.cpp | |
| parent | Fix typo in release notes. (diff) | |
| download | discoin-e22c0671c74bc4db70b3ba04d093cd110f9f22a7.tar.xz discoin-e22c0671c74bc4db70b3ba04d093cd110f9f22a7.zip | |
Fix for issue #9775. Added check for open() returning a NULL pointer.
Github-Pull: #9798
Rebased-From: 40f11f8872c3e9f380f8278f984dfdabffe77539
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/util.cpp b/src/util.cpp index ba157625d..78c353dfe 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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; -} +}
\ No newline at end of file |