diff options
author | M. Kristall <mkpdev@gmail.com> | 2011-02-07 02:31:53 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:17:58 +0000 |
commit | 2c0695c52d281bf30f08d613e31588db19ebc4e2 (patch) | |
tree | c3bf575bbd1313a8d99be2f0688e7d5eff8843f5 /src | |
parent | 260fac5d9d33140369444f57a1819430bc6dd1f4 (diff) |
* Fix uninitialized variable usage after failed name match in some cases
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_cmds.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 51f5ea65..68a251b9 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -90,11 +90,25 @@ int G_ClientNumberFromString( char *s, char *err, int len ) cl = &level.clients[ i ]; if( cl->pers.connected == CON_DISCONNECTED ) + { + if( p ) + Q_strncpyz( p, "no player connected in that slot #\n", len ); + return -1; + } return i; } + G_SanitiseString( s, s2, sizeof( s2 ) ); + if( !s2[ 0 ] ) + { + if( p ) + Q_strncpyz( p, "no player name provided\n", len ); + + return -1; + } + if( p ) { Q_strncpyz( p, "more than one player name matches. " @@ -105,9 +119,6 @@ int G_ClientNumberFromString( char *s, char *err, int len ) } // check for a name match - G_SanitiseString( s, s2, sizeof( s2 ) ); - if( !s2[ 0 ] ) - return -1; for( i = 0, cl = level.clients; i < level.maxclients; i++, cl++ ) { if( cl->pers.connected == CON_DISCONNECTED ) |