commit cc4ec3b0ef2e748e9b007a1e495f9356f6aa3de9
Author: Andrea Musuruane <musuruan(a)gmail.com>
Date: Fri May 6 08:47:36 2022 +0200
Fix segfault at startup (BZ #6252). Thanks to Ingo van Lil.
Use %set_build_flags macro
frogatto-1.3.3-sdl.patch | 38 +++++++++++++++++++++++++++++++++++++
frogatto-1.3.3-stack-overflow.patch | 26 +++++++++++++++++++++++++
frogatto.spec | 22 ++++++++++++++++++---
3 files changed, 83 insertions(+), 3 deletions(-)
---
diff --git a/frogatto-1.3.3-sdl.patch b/frogatto-1.3.3-sdl.patch
new file mode 100644
index 0000000..cf5ac73
--- /dev/null
+++ b/frogatto-1.3.3-sdl.patch
@@ -0,0 +1,38 @@
+From 7de047326ad5f91da0a1faa62e25eaa163cdda36 Mon Sep 17 00:00:00 2001
+From: Ingo van Lil <inguin(a)gmx.de>
+Date: Mon, 25 Apr 2022 07:29:56 +0200
+Subject: [PATCH 1/2] Work around surface double free with sdl12-compat
+
+The SDL 1.2 compatibility library disregards the surface's refcount
+field in SDL_FreeSurface, causing a double free in Frogatto. A bugfix is
+available in commit [1], but not yet released. Work around by handling
+the refcount ourselves.
+
+This patch can be removed when RPMs for sdl12-compat newer than 1.2.52
+are available, but it should be safe even then.
+
+[1]
https://github.com/libsdl-org/sdl12-compat/commit/201670ec
+---
+ src/surface.hpp | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/surface.hpp b/src/surface.hpp
+index 216051f54..ec26d76ee 100644
+--- a/src/surface.hpp
++++ b/src/surface.hpp
+@@ -42,7 +42,11 @@ private:
+ void operator()(SDL_Surface *surf) const
+ {
+ if (surf != NULL) {
+- SDL_FreeSurface(surf);
++ if (surf->refcount > 1) {
++ --surf->refcount;
++ } else {
++ SDL_FreeSurface(surf);
++ }
+ }
+ }
+ };
+--
+2.35.1
+
diff --git a/frogatto-1.3.3-stack-overflow.patch b/frogatto-1.3.3-stack-overflow.patch
new file mode 100644
index 0000000..4984f81
--- /dev/null
+++ b/frogatto-1.3.3-stack-overflow.patch
@@ -0,0 +1,26 @@
+From e9308875d2d8b552722b3b13fbf67cf630c3e8d1 Mon Sep 17 00:00:00 2001
+From: Ingo van Lil <inguin(a)gmx.de>
+Date: Mon, 25 Apr 2022 08:15:52 +0200
+Subject: [PATCH 2/2] Fix stack overflow in base64 test
+
+Reserve space for terminating 0 character in destination string.
+---
+ src/level_object.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/level_object.cpp b/src/level_object.cpp
+index 097b97a3c..13ff75992 100644
+--- a/src/level_object.cpp
++++ b/src/level_object.cpp
+@@ -908,7 +908,7 @@ UNIT_TEST(level_object_base64)
+ const char* s = "4O0";
+ const char* s2 = s + strlen(s);
+ const int num = base64_unencode(s, s2);
+- char buf[3];
++ char buf[4];
+ base64_encode(num, buf, 3);
+ CHECK_EQ(buf[0], s[0]);
+ CHECK_EQ(buf[1], s[1]);
+--
+2.35.1
+
diff --git a/frogatto.spec b/frogatto.spec
index 4ff4284..9dc3c9e 100644
--- a/frogatto.spec
+++ b/frogatto.spec
@@ -3,7 +3,7 @@
Name: frogatto
Version: 1.3.3
-Release: 24%{?dist}
+Release: 25%{?dist}
Summary: An old-school 2D platform game
# Artwork and music not released under an open license
@@ -28,6 +28,13 @@ Patch3: %{name}-1.3-narrowing-conversion-fixes.patch
Patch4: %{name}-1.3-comparison.patch
# Fix building with Boost 1.70+
Patch5: %{name}-1.3-boost.patch
+# Fix stack overflow in base64 test
+# Patch by Ingo van Lil
+Patch6: %{name}-1.3.3-stack-overflow.patch
+# Work around surface double free with sdl12-compat
+# This needs to be removed once sdl12-compat > 1.2.52 is released
+# Patch by Ingo van Lil
+Patch7: %{name}-1.3.3-sdl.patch
# We have problems with these architectures
#
https://lists.rpmfusion.org/archives/list/rpmfusion-developers@lists.rpmf...
@@ -69,14 +76,19 @@ in game, and work to unravel Big Bad Milgram's plot against the
townsfolk!
%patch3 -p1
%patch4 -p1
%patch5 -p0
+%patch6 -p1
+%patch7 -p1
# Fix locale file path
sed -i 's!"./locale/"!"%{_datadir}/locale/"!' src/i18n.cpp
+# Edit BASE_CXXFLAGS
+sed -i 's/BASE_CXXFLAGS += -g -fno-inline-functions -fthreadsafe-statics
-Wnon-virtual-dtor -Werror -Wignored-qualifiers -Wformat -Wswitch/BASE_CXXFLAGS +=
-fno-inline-functions -fthreadsafe-statics -Wno-narrowing/' Makefile
+
%build
-%make_build \
- BASE_CXXFLAGS="$RPM_OPT_FLAGS -fno-inline-functions -fthreadsafe-statics
-Wno-narrowing"
+%set_build_flags
+%make_build
%install
@@ -144,6 +156,10 @@ appstream-util validate-relax --nonet \
%changelog
+* Tue Apr 26 2022 Andrea Musuruane <musuruan(a)gmail.com> - 1.3.3-25
+- Fix segfault at startup (BZ #6252). Thanks to Ingo van Lil.
+- Use %%set_build_flags macro
+
* Mon Feb 14 2022 Sérgio Basto <sergio(a)serjux.com> - 1.3.3-24
- Rebuid for glew-2.2.0