Don't call SDL_FreeSurface with null pointer
authorunc0rr
Thu, 04 Dec 2008 21:14:03 +0000
changeset 1525 311d0ab35d98
parent 1524 5a652a465559
child 1526 18e412dd7d50
Don't call SDL_FreeSurface with null pointer
hedgewars/CCHandlers.inc
hedgewars/uStore.pas
--- a/hedgewars/CCHandlers.inc	Mon Dec 01 14:24:17 2008 +0000
+++ b/hedgewars/CCHandlers.inc	Thu Dec 04 21:14:03 2008 +0000
@@ -481,7 +481,7 @@
 {$IFDEF DEBUGFILE}
 AddFileLog('Freeing old primary surface...');
 {$ENDIF}
-SDL_FreeSurface(SDLPrimSurface);
+if SDLPrimSurface <> nil then SDL_FreeSurface(SDLPrimSurface);
 
 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
 SDLTry(SDLPrimSurface <> nil, true);
--- a/hedgewars/uStore.pas	Mon Dec 01 14:24:17 2008 +0000
+++ b/hedgewars/uStore.pas	Thu Dec 04 21:14:03 2008 +0000
@@ -45,8 +45,8 @@
 function  LoadImage(const filename: string; hasAlpha, critical, setTransparent: boolean): PSDL_Surface;
 procedure SetupOpenGL;
 
-var PixelFormat: PSDL_PixelFormat;
- SDLPrimSurface: PSDL_Surface;
+var PixelFormat: PSDL_PixelFormat = nil;
+ SDLPrimSurface: PSDL_Surface = nil;
    PauseTexture,
    ConfirmTexture: PTexture;