Skip to content

Commit 76f344d

Browse files
logging: Fix potential use-after-free in LogPrintStr(...)
1 parent 57c57df commit 76f344d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/logging.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,11 @@ int BCLog::Logger::LogPrintStr(const std::string &str)
222222
// reopen the log file, if requested
223223
if (m_reopen_file) {
224224
m_reopen_file = false;
225-
if (fsbridge::freopen(m_file_path,"a",m_fileout) != nullptr)
226-
setbuf(m_fileout, nullptr); // unbuffered
225+
m_fileout = fsbridge::freopen(m_file_path, "a", m_fileout);
226+
if (!m_fileout) {
227+
return ret;
228+
}
229+
setbuf(m_fileout, nullptr); // unbuffered
227230
}
228231

229232
ret = FileWriteStr(strTimestamped, m_fileout);

0 commit comments

Comments
 (0)