From d0da0be31a73e9367aed67e5c31aef3916195b4e Mon Sep 17 00:00:00 2001 From: jbeich Date: Fri, 6 Oct 2017 13:12:41 +0000 Subject: [PATCH] MFH: r451381 devel/sdl20: crashfix for some consumers after r450461 $ pkg install pioneer $ pioneer [...] ShipType::Init() Lua::Init() Server agent disabled Thread 1 received signal SIGSEGV, Segmentation fault. 0x0000000800cd5d20 in SDL_ConvertSurface_REAL (surface=0x80b374fc0, format=0xb4c7e8 , flags=0) at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/video/SDL_surface.c:936 936 copy_flags = surface->map->info.flags; (gdb) p surface->map $1 = (struct SDL_BlitMap *) 0x0 (gdb) bt #0 0x0000000800cd5d20 in SDL_ConvertSurface_REAL (surface=0x80b374fc0, format=0xb4c7e8 , flags=0) at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/video/SDL_surface.c:936 #1 0x0000000800c099d2 in SDL_ConvertSurface (a=0x80b374fc0, b=0xb4c7e8 , c=0) at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/dynapi/SDL_dynapi_procs.h:492 #2 0x000000000081cfbb in Graphics::TextureBuilder::PrepareSurface (this=0x7fffffffac50) at TextureBuilder.cpp:117 #3 0x00000000003a0699 in Graphics::TextureBuilder::GetDescriptor (this=0x7fffffffac50) at ./graphics/TextureBuilder.h:48 [...] PR: 222822 Obtained from: upstream Submitted by: lightside@gmx.com Approved by: ports-secteam blanket --- devel/sdl20/Makefile | 1 + .../files/patch-src_video_SDL__surface.c | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 devel/sdl20/files/patch-src_video_SDL__surface.c diff --git a/devel/sdl20/Makefile b/devel/sdl20/Makefile index 5bdfc215ad5f..bd1823776eda 100644 --- a/devel/sdl20/Makefile +++ b/devel/sdl20/Makefile @@ -2,6 +2,7 @@ PORTNAME= sdl2 PORTVERSION= 2.0.6 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= http://www.libsdl.org/release/ DISTNAME= SDL2-${PORTVERSION} diff --git a/devel/sdl20/files/patch-src_video_SDL__surface.c b/devel/sdl20/files/patch-src_video_SDL__surface.c new file mode 100644 index 000000000000..ba55080fa22f --- /dev/null +++ b/devel/sdl20/files/patch-src_video_SDL__surface.c @@ -0,0 +1,31 @@ +SDL_FreeSurface deallocates surface->map even if the surface is not yet freed +https://bugzilla.libsdl.org/show_bug.cgi?id=3852 + +Memory leak in SDL_FreeSurface (after bug 3852 fix) +https://bugzilla.libsdl.org/show_bug.cgi?id=3855 + +--- src/video/SDL_surface.c.orig 2017-09-22 18:51:01 UTC ++++ src/video/SDL_surface.c +@@ -1198,10 +1198,8 @@ SDL_FreeSurface(SDL_Surface * surface) + if (surface->flags & SDL_DONTFREE) { + return; + } +- if (surface->map != NULL) { +- SDL_FreeBlitMap(surface->map); +- surface->map = NULL; +- } ++ SDL_InvalidateMap(surface->map); ++ + if (--surface->refcount > 0) { + return; + } +@@ -1219,6 +1217,9 @@ SDL_FreeSurface(SDL_Surface * surface) + if (!(surface->flags & SDL_PREALLOC)) { + SDL_free(surface->pixels); + } ++ if (surface->map) { ++ SDL_FreeBlitMap(surface->map); ++ } + SDL_free(surface); + } +