|
Line 0
Link Here
|
|
|
1 |
# Origin: https://hg.libsdl.org/SDL/rev/a09c3f87a12f |
| 2 |
# Subject: Fixed bug 3852 - SDL_FreeSurface deallocates surface->map even if |
| 3 |
# the surface is not yet freed |
| 4 |
# Origin: https://hg.libsdl.org/SDL/rev/3a23ca106752 |
| 5 |
# Subject: Fixed bug 3855 - Memory leak in SDL_FreeSurface |
| 6 |
|
| 7 |
--- src/video/SDL_surface.c.orig 2017-09-22 18:51:01 UTC |
| 8 |
+++ src/video/SDL_surface.c |
| 9 |
@@ -1198,10 +1198,8 @@ SDL_FreeSurface(SDL_Surface * surface) |
| 10 |
if (surface->flags & SDL_DONTFREE) { |
| 11 |
return; |
| 12 |
} |
| 13 |
- if (surface->map != NULL) { |
| 14 |
- SDL_FreeBlitMap(surface->map); |
| 15 |
- surface->map = NULL; |
| 16 |
- } |
| 17 |
+ SDL_InvalidateMap(surface->map); |
| 18 |
+ |
| 19 |
if (--surface->refcount > 0) { |
| 20 |
return; |
| 21 |
} |
| 22 |
@@ -1219,6 +1217,9 @@ SDL_FreeSurface(SDL_Surface * surface) |
| 23 |
if (!(surface->flags & SDL_PREALLOC)) { |
| 24 |
SDL_free(surface->pixels); |
| 25 |
} |
| 26 |
+ if (surface->map) { |
| 27 |
+ SDL_FreeBlitMap(surface->map); |
| 28 |
+ } |
| 29 |
SDL_free(surface); |
| 30 |
} |
| 31 |
|