IOFile: avoid clearing errors on null file struct

When performing a default compilation with recent GCC & glibc,
the use of -Werror=nonnull causes a build error.

The error is given as IOFile::ClearError() can call std::clearerr()
with a null file, which can trigger a null-pointer dereference in libc.

Change the std::clearerr() call to be conditional on a file being open.
This commit is contained in:
Peter Lafreniere 2024-02-11 20:55:31 -05:00
parent aa66842172
commit 3da2e15e6b
1 changed files with 2 additions and 1 deletions

View File

@ -116,7 +116,8 @@ public:
void ClearError()
{
m_good = true;
std::clearerr(m_file);
if (IsOpen())
std::clearerr(m_file);
}
private: