diff options
| author | Wladimir J. van der Laan <[email protected]> | 2017-02-21 14:32:44 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-02-21 14:32:58 +0100 |
| commit | 8ad31f9aa3111e079dd5024e8f6b069abb564b81 (patch) | |
| tree | 6b0a733549ce45ea5a6a752eb38a42aa6ac2ace8 /src | |
| parent | Merge #9813: Read/write mempool.dat as a binary. (diff) | |
| parent | Fix for issue #9775. Added check for open() returning a NULL pointer. (diff) | |
| download | discoin-8ad31f9aa3111e079dd5024e8f6b069abb564b81.tar.xz discoin-8ad31f9aa3111e079dd5024e8f6b069abb564b81.zip | |
Merge #9798: Fix Issue #9775 (Check returned value of fopen)
40f11f8 Fix for issue #9775. Added check for open() returning a NULL pointer. (kirit93)
Diffstat (limited to 'src')
| -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 |