--- Makefile (revision 451359) +++ Makefile (working copy) @@ -2,6 +2,7 @@ PORTNAME= sdl2 PORTVERSION= 2.0.6 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= http://www.libsdl.org/release/ DISTNAME= SDL2-${PORTVERSION} --- files/patch-src_video_SDL__surface.c (nonexistent) +++ files/patch-src_video_SDL__surface.c (working copy) @@ -0,0 +1,31 @@ +# Origin: https://hg.libsdl.org/SDL/rev/a09c3f87a12f +# Subject: Fixed bug 3852 - SDL_FreeSurface deallocates surface->map even if +# the surface is not yet freed +# Origin: https://hg.libsdl.org/SDL/rev/3a23ca106752 +# Subject: Fixed bug 3855 - Memory leak in SDL_FreeSurface + +--- 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); + } +