diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-02-21 14:32:44 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-02-21 14:32:58 +0100 |
commit | 8ad31f9aa3111e079dd5024e8f6b069abb564b81 (patch) | |
tree | 6b0a733549ce45ea5a6a752eb38a42aa6ac2ace8 /src | |
parent | 7d46b3ea8d6cd835bd0bbd3e8e9a6d7a6a536c31 (diff) | |
parent | 40f11f8872c3e9f380f8278f984dfdabffe77539 (diff) | |
download | bitcoin-8ad31f9aa3111e079dd5024e8f6b069abb564b81.tar.xz |
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 ba157625d8..78c353dfe5 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 |