summaryrefslogtreecommitdiff
path: root/src/sdl/sdl_glimp.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2015-06-28 18:01:03 +0100
committerTim Angus <tim@ngus.net>2016-04-07 11:02:28 +0100
commitcd73fc454e392d04156582984bccb4289307b2f3 (patch)
treec54e8ffdc65f207d5d1605d20d49fe0188959488 /src/sdl/sdl_glimp.c
parent2968a5e514c62e9df4528b43a3d089c965536b43 (diff)
Check SDL_GetNumDisplayModes return value for errors
Diffstat (limited to 'src/sdl/sdl_glimp.c')
-rw-r--r--src/sdl/sdl_glimp.c8
1 files changed, 4 insertions, 4 deletions
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" );