From cd73fc454e392d04156582984bccb4289307b2f3 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sun, 28 Jun 2015 18:01:03 +0100 Subject: Check SDL_GetNumDisplayModes return value for errors --- src/sdl/sdl_glimp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sdl/sdl_glimp.c') diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c index ffda45a0..2141c2bb 100644 --- a/src/sdl/sdl_glimp.c +++ b/src/sdl/sdl_glimp.c @@ -135,21 +135,21 @@ static void GLimp_DetectAvailableModes(void) { int i, j; char buf[ MAX_STRING_CHARS ] = { 0 }; - size_t numSDLModes; + int numSDLModes; SDL_Rect *modes; int numModes = 0; int display = SDL_GetWindowDisplayIndex( SDL_window ); + numSDLModes = SDL_GetNumDisplayModes( display ); SDL_DisplayMode windowMode; - if( SDL_GetWindowDisplayMode( SDL_window, &windowMode ) < 0 ) + if( SDL_GetWindowDisplayMode( SDL_window, &windowMode ) < 0 || numSDLModes <= 0 ) { ri.Printf( PRINT_WARNING, "Couldn't get window display mode, no resolutions detected\n" ); return; } - numSDLModes = SDL_GetNumDisplayModes( display ); - modes = SDL_calloc( numSDLModes, sizeof( SDL_Rect ) ); + modes = SDL_calloc( (size_t)numSDLModes, sizeof( SDL_Rect ) ); if ( !modes ) { ri.Error( ERR_FATAL, "Out of memory" ); -- cgit