summaryrefslogtreecommitdiff
path: root/Source/Core/Common/IOFile.h
diff options
context:
space:
mode:
authorPeter Lafreniere <peter@n8pjl.ca>2024-02-11 20:55:31 -0500
committerPeter Lafreniere <peter@n8pjl.ca>2024-02-11 20:55:31 -0500
commit3da2e15e6b95f02f66df461e87c8b896e450fdab (patch)
treec4a1978e69335790e009cba0ba9e6e168a5ef482 /Source/Core/Common/IOFile.h
parentaa66842172da29b2936fdb0942d32947ae1b3ca1 (diff)
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.
Diffstat (limited to 'Source/Core/Common/IOFile.h')
-rw-r--r--Source/Core/Common/IOFile.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/Source/Core/Common/IOFile.h b/Source/Core/Common/IOFile.h
index 4b12c31888..b5895333b1 100644
--- a/Source/Core/Common/IOFile.h
+++ b/Source/Core/Common/IOFile.h
@@ -116,7 +116,8 @@ public:
void ClearError()
{
m_good = true;
- std::clearerr(m_file);
+ if (IsOpen())
+ std::clearerr(m_file);
}
private: