Fixed NULL pointer dereference
authorSam Lantinga <slouken@libsdl.org>
Tue, 13 Jan 2009 03:53:22 +0000
changeset 30340e821769fc51
parent 3033 4e4f47c5f941
child 3035 ff602fdfdedc
Fixed NULL pointer dereference
CREDITS
include/SDL_compat.h
src/SDL_compat.c
     1.1 --- a/CREDITS	Mon Jan 12 22:36:12 2009 +0000
     1.2 +++ b/CREDITS	Tue Jan 13 03:53:22 2009 +0000
     1.3 @@ -25,8 +25,9 @@
     1.4  * Szymon "Wilku" Wilczek for adding support for multiple mice and tablets
     1.5    during the Google Summer of Code 2008
     1.6  
     1.7 -* Marty Leisner, Andrew, Will, Edgar Simo, Donny Viszneki, and Couriersud
     1.8 -  for helping find SDL 1.3 bugs in the great SDL Bug Hunt of January 2009!
     1.9 +* Marty Leisner, Andrew, Will, Edgar Simo, Donny Viszneki, Andrea Mazzoleni,
    1.10 +  and Couriersud for helping find SDL 1.3 bugs in the great SDL Bug Hunt
    1.11 +  of January 2009!
    1.12  
    1.13  * Donny Viszneki for helping fix SDL 1.3 bugs in the great SDL Bug Hunt of
    1.14    January 2009!
     2.1 --- a/include/SDL_compat.h	Mon Jan 12 22:36:12 2009 +0000
     2.2 +++ b/include/SDL_compat.h	Tue Jan 13 03:53:22 2009 +0000
     2.3 @@ -228,8 +228,7 @@
     2.4  extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
     2.5                                              int height,
     2.6                                              int bpp, Uint32 flags);
     2.7 -extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(SDL_PixelFormat * format,
     2.8 -                                                 Uint32 flags);
     2.9 +extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags);
    2.10  extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width,
    2.11                                                        int height,
    2.12                                                        int bpp, Uint32 flags);
     3.1 --- a/src/SDL_compat.c	Mon Jan 12 22:36:12 2009 +0000
     3.2 +++ b/src/SDL_compat.c	Tue Jan 13 03:53:22 2009 +0000
     3.3 @@ -114,7 +114,7 @@
     3.4  }
     3.5  
     3.6  SDL_Rect **
     3.7 -SDL_ListModes(SDL_PixelFormat * format, Uint32 flags)
     3.8 +SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags)
     3.9  {
    3.10      int i, nmodes;
    3.11      SDL_Rect **modes;
    3.12 @@ -127,6 +127,10 @@
    3.13          return (SDL_Rect **) (-1);
    3.14      }
    3.15  
    3.16 +    if (!format) {
    3.17 +        format = SDL_GetVideoInfo()->vfmt;
    3.18 +    }
    3.19 +
    3.20      /* Memory leak, but this is a compatibility function, who cares? */
    3.21      nmodes = 0;
    3.22      modes = NULL;