summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2010-12-10 23:56:32 +0000
committerSimon Howard2010-12-10 23:56:32 +0000
commit57a9f56e2cba50249ee8a96533c8baed47814f92 (patch)
tree1f208956a8155f70db59756800e223d2e07b8891
parente225e0c93ce58bb0e33c174847305d39800fd755 (diff)
downloadchocolate-doom-57a9f56e2cba50249ee8a96533c8baed47814f92.tar.gz
chocolate-doom-57a9f56e2cba50249ee8a96533c8baed47814f92.tar.bz2
chocolate-doom-57a9f56e2cba50249ee8a96533c8baed47814f92.zip
Fix memory leak when dynamically resizing window in true color video
modes. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2215
-rw-r--r--src/i_video.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/i_video.c b/src/i_video.c
index 488c08a0..ad4d7f39 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -97,7 +97,7 @@ static SDL_Surface *screen;
// This is used when we are rendering in 32-bit screen mode.
// When in a real 8-bit screen mode, screenbuffer == screen.
-static SDL_Surface *screenbuffer;
+static SDL_Surface *screenbuffer = NULL;
// palette
@@ -1646,6 +1646,14 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h)
doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE);
+ // If we are already running and in a true color mode, we need
+ // to free the screenbuffer surface before setting the new mode.
+
+ if (screenbuffer != NULL && screen != screenbuffer)
+ {
+ SDL_FreeSurface(screenbuffer);
+ }
+
// Generate lookup tables before setting the video mode.
if (mode != NULL && mode->InitMode != NULL)