Skip to content

Commit

Permalink
logging: Fix potential use-after-free in LogPrintStr(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift committed May 2, 2018
1 parent 57c57df commit 76f344d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 76f344d

Please sign in to comment.