games-emulation/dolphin: Backport gcc-14 build fix

Thanks to Kostadin Shishmanov for finding the pull request.

Closes: https://bugs.gentoo.org/933203
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny 2024-06-02 19:50:39 +02:00
parent 1228641af8
commit 1e3866a781
No known key found for this signature in database
GPG Key ID: 639ADAE2329E240E
2 changed files with 35 additions and 1 deletions

View File

@ -35,7 +35,11 @@ IUSE="
profile pulseaudio systemd upnp vulkan
"
PATCHES=("${FILESDIR}/${P}-libfmt-9.0.0-fix-build.patch")
PATCHES=(
"${FILESDIR}/${P}-libfmt-9.0.0-fix-build.patch"
# https://github.com/dolphin-emu/dolphin/pull/12575
"${FILESDIR}/${P}-gcc-14.patch"
)
RDEPEND="
app-arch/bzip2:=

View File

@ -0,0 +1,30 @@
From 3da2e15e6b95f02f66df461e87c8b896e450fdab Mon Sep 17 00:00:00 2001
From: Peter Lafreniere <peter@n8pjl.ca>
Date: Sun, 11 Feb 2024 20:55:31 -0500
Subject: [PATCH] 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.
---
Source/Core/Common/IOFile.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Source/Core/Common/IOFile.h b/Source/Core/Common/IOFile.h
index 4b12c3188853..b5895333b1be 100644
--- a/Source/Core/Common/IOFile.h
+++ b/Source/Core/Common/IOFile.h
@@ -116,7 +116,8 @@ class IOFile
void ClearError()
{
m_good = true;
- std::clearerr(m_file);
+ if (IsOpen())
+ std::clearerr(m_file);
}
private: