From 76f344de6d144e0a8169594836575a5812157327 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 2 May 2018 10:43:17 +0200 Subject: logging: Fix potential use-after-free in LogPrintStr(...) --- src/logging.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/logging.cpp b/src/logging.cpp index 10a3b18958..6046969375 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -222,8 +222,11 @@ int BCLog::Logger::LogPrintStr(const std::string &str) // reopen the log file, if requested if (m_reopen_file) { m_reopen_file = false; - if (fsbridge::freopen(m_file_path,"a",m_fileout) != nullptr) - setbuf(m_fileout, nullptr); // unbuffered + m_fileout = fsbridge::freopen(m_file_path, "a", m_fileout); + if (!m_fileout) { + return ret; + } + setbuf(m_fileout, nullptr); // unbuffered } ret = FileWriteStr(strTimestamped, m_fileout); -- cgit v1.2.3