mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
Check SDL_GetNumDisplayModes return value for errors
This commit is contained in:
parent
ea9161f4a3
commit
61825d8e5f
1 changed files with 4 additions and 4 deletions
|
@ -130,21 +130,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" );
|
||||
|
|
Loading…
Reference in a new issue