diff options
| author | Peter Lafreniere <peter@n8pjl.ca> | 2024-02-11 20:55:31 -0500 |
|---|---|---|
| committer | Peter Lafreniere <peter@n8pjl.ca> | 2024-02-11 20:55:31 -0500 |
| commit | 3da2e15e6b95f02f66df461e87c8b896e450fdab (patch) | |
| tree | c4a1978e69335790e009cba0ba9e6e168a5ef482 /Source/Core/Common/IOFile.h | |
| parent | aa66842172da29b2936fdb0942d32947ae1b3ca1 (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.h | 3 |
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: |
