From c39a689d5f812a617c362795ed5b211bbd35c832 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jan 2009 03:53:22 +0000 Subject: [PATCH] Fixed NULL pointer dereference --- CREDITS | 5 +++-- include/SDL_compat.h | 3 +-- src/SDL_compat.c | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CREDITS b/CREDITS index f3ee38159..f7e616a31 100644 --- a/CREDITS +++ b/CREDITS @@ -25,8 +25,9 @@ Thanks to everyone who made this possible, including: * Szymon "Wilku" Wilczek for adding support for multiple mice and tablets during the Google Summer of Code 2008 -* Marty Leisner, Andrew, Will, Edgar Simo, Donny Viszneki, and Couriersud - for helping find SDL 1.3 bugs in the great SDL Bug Hunt of January 2009! +* Marty Leisner, Andrew, Will, Edgar Simo, Donny Viszneki, Andrea Mazzoleni, + and Couriersud for helping find SDL 1.3 bugs in the great SDL Bug Hunt + of January 2009! * Donny Viszneki for helping fix SDL 1.3 bugs in the great SDL Bug Hunt of January 2009! diff --git a/include/SDL_compat.h b/include/SDL_compat.h index 9294d74a0..1fa5da46c 100644 --- a/include/SDL_compat.h +++ b/include/SDL_compat.h @@ -228,8 +228,7 @@ extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void); extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); -extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(SDL_PixelFormat * format, - Uint32 flags); +extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags); extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags); diff --git a/src/SDL_compat.c b/src/SDL_compat.c index 1037b7978..88a16c5f1 100644 --- a/src/SDL_compat.c +++ b/src/SDL_compat.c @@ -114,7 +114,7 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) } SDL_Rect ** -SDL_ListModes(SDL_PixelFormat * format, Uint32 flags) +SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags) { int i, nmodes; SDL_Rect **modes; @@ -127,6 +127,10 @@ SDL_ListModes(SDL_PixelFormat * format, Uint32 flags) return (SDL_Rect **) (-1); } + if (!format) { + format = SDL_GetVideoInfo()->vfmt; + } + /* Memory leak, but this is a compatibility function, who cares? */ nmodes = 0; modes = NULL;