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 41605e1dbf83b2c4493d91245117f601874efba8
Author: MAN-AT-ARMS <m4n4t4...@gmail.com>
Date:   Sat Jun 13 06:51:46 2015 -0400

    All: Don't crash if more than 128 modes are available
---
 MP/code/sdl/sdl_glimp.c | 14 ++++++++++++--
 SP/code/sdl/sdl_glimp.c | 14 ++++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/MP/code/sdl/sdl_glimp.c b/MP/code/sdl/sdl_glimp.c
index 1f3cb63..9b49752 100644
--- a/MP/code/sdl/sdl_glimp.c
+++ b/MP/code/sdl/sdl_glimp.c
@@ -157,7 +157,8 @@ static void GLimp_DetectAvailableModes(void)
 {
        int i, j;
        char buf[ MAX_STRING_CHARS ] = { 0 };
-       SDL_Rect modes[ 128 ];
+       size_t numSDLModes;
+       SDL_Rect *modes;
        int numModes = 0;
 
        int display = SDL_GetWindowDisplayIndex( SDL_window );
@@ -169,7 +170,14 @@ static void GLimp_DetectAvailableModes(void)
                return;
        }
 
-       for( i = 0; i < SDL_GetNumDisplayModes( display ); i++ )
+       numSDLModes = SDL_GetNumDisplayModes( display );
+       modes = SDL_calloc( numSDLModes, sizeof( SDL_Rect ) );
+       if ( !modes )
+       {
+               ri.Error( ERR_FATAL, "Out of memory" );
+       }
+
+       for( i = 0; i < numSDLModes; i++ )
        {
                SDL_DisplayMode mode;
 
@@ -179,6 +187,7 @@ static void GLimp_DetectAvailableModes(void)
                if( !mode.w || !mode.h )
                {
                        ri.Printf( PRINT_ALL, "Display supports any 
resolution\n" );
+                       SDL_free( modes );
                        return;
                }
 
@@ -220,6 +229,7 @@ static void GLimp_DetectAvailableModes(void)
                ri.Printf( PRINT_ALL, "Available modes: '%s'\n", buf );
                ri.Cvar_Set( "r_availableModes", buf );
        }
+       SDL_free( modes );
 }
 
 /*
diff --git a/SP/code/sdl/sdl_glimp.c b/SP/code/sdl/sdl_glimp.c
index 1f3cb63..9b49752 100644
--- a/SP/code/sdl/sdl_glimp.c
+++ b/SP/code/sdl/sdl_glimp.c
@@ -157,7 +157,8 @@ static void GLimp_DetectAvailableModes(void)
 {
        int i, j;
        char buf[ MAX_STRING_CHARS ] = { 0 };
-       SDL_Rect modes[ 128 ];
+       size_t numSDLModes;
+       SDL_Rect *modes;
        int numModes = 0;
 
        int display = SDL_GetWindowDisplayIndex( SDL_window );
@@ -169,7 +170,14 @@ static void GLimp_DetectAvailableModes(void)
                return;
        }
 
-       for( i = 0; i < SDL_GetNumDisplayModes( display ); i++ )
+       numSDLModes = SDL_GetNumDisplayModes( display );
+       modes = SDL_calloc( numSDLModes, sizeof( SDL_Rect ) );
+       if ( !modes )
+       {
+               ri.Error( ERR_FATAL, "Out of memory" );
+       }
+
+       for( i = 0; i < numSDLModes; i++ )
        {
                SDL_DisplayMode mode;
 
@@ -179,6 +187,7 @@ static void GLimp_DetectAvailableModes(void)
                if( !mode.w || !mode.h )
                {
                        ri.Printf( PRINT_ALL, "Display supports any 
resolution\n" );
+                       SDL_free( modes );
                        return;
                }
 
@@ -220,6 +229,7 @@ static void GLimp_DetectAvailableModes(void)
                ri.Printf( PRINT_ALL, "Available modes: '%s'\n", buf );
                ri.Cvar_Set( "r_availableModes", buf );
        }
+       SDL_free( modes );
 }
 
 /*

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

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to