[iortcw] 351/497: All: Check SDL_GetNumDisplayModes return value for errors

Simon McVittie smcv at debian.org
Fri Sep 8 10:37:26 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 6f1531c9482208b3f773b1a21aa4163063e286dc
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Tue Jun 30 20:25:16 2015 -0400

    All: Check SDL_GetNumDisplayModes return value for errors
---
 MP/code/sdl/sdl_glimp.c | 10 +++++-----
 SP/code/sdl/sdl_glimp.c | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/MP/code/sdl/sdl_glimp.c b/MP/code/sdl/sdl_glimp.c
index 9b49752..f92aa4c 100644
--- a/MP/code/sdl/sdl_glimp.c
+++ b/MP/code/sdl/sdl_glimp.c
@@ -157,21 +157,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 );
 	SDL_DisplayMode windowMode;
+	int display = SDL_GetWindowDisplayIndex( SDL_window );
+	numSDLModes = SDL_GetNumDisplayModes( display );
 
-	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" );
diff --git a/SP/code/sdl/sdl_glimp.c b/SP/code/sdl/sdl_glimp.c
index 9b49752..f92aa4c 100644
--- a/SP/code/sdl/sdl_glimp.c
+++ b/SP/code/sdl/sdl_glimp.c
@@ -157,21 +157,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 );
 	SDL_DisplayMode windowMode;
+	int display = SDL_GetWindowDisplayIndex( SDL_window );
+	numSDLModes = SDL_GetNumDisplayModes( display );
 
-	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" );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list