Skip to content

Commit

Permalink
MFH: r451381
Browse files Browse the repository at this point in the history
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 <Graphics::pixelFormatRGBA>, 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 <Graphics::pixelFormatRGBA>, 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 <Graphics::pixelFormatRGBA>, 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
  • Loading branch information
jbeich committed Oct 6, 2017
1 parent fb62414 commit d0da0be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions devel/sdl20/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

PORTNAME= sdl2
PORTVERSION= 2.0.6
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= http://www.libsdl.org/release/
DISTNAME= SDL2-${PORTVERSION}
Expand Down
31 changes: 31 additions & 0 deletions devel/sdl20/files/patch-src_video_SDL__surface.c
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit d0da0be

Please sign in to comment.