Fix demoName Com_sprintf size larger than buffer

Maybe this is why demoName is a static global with the comment 'compiler bug workaround'?
This commit is contained in:
Zack Middleton 2014-01-12 16:07:49 -06:00
parent 43c6ebee8d
commit 52e72408d9

View file

@ -670,7 +670,7 @@ void CL_StopRecord_f( void ) {
CL_DemoFilename CL_DemoFilename
================== ==================
*/ */
void CL_DemoFilename( int number, char *fileName ) { void CL_DemoFilename( int number, char *fileName, int fileNameSize ) {
int a,b,c,d; int a,b,c,d;
if(number < 0 || number > 9999) if(number < 0 || number > 9999)
@ -684,7 +684,7 @@ void CL_DemoFilename( int number, char *fileName ) {
number -= c*10; number -= c*10;
d = number; d = number;
Com_sprintf( fileName, MAX_OSPATH, "demo%i%i%i%i" Com_sprintf( fileName, fileNameSize, "demo%i%i%i%i"
, a, b, c, d ); , a, b, c, d );
} }
@ -744,7 +744,7 @@ void CL_Record_f( void ) {
// scan for a free demo name // scan for a free demo name
for ( number = 0 ; number <= 9999 ; number++ ) { for ( number = 0 ; number <= 9999 ; number++ ) {
CL_DemoFilename( number, demoName ); CL_DemoFilename( number, demoName, sizeof( demoName ) );
#ifdef LEGACY_PROTOCOL #ifdef LEGACY_PROTOCOL
if(clc.compat) if(clc.compat)
Com_sprintf(name, sizeof(name), "demos/%s.%s%d", demoName, DEMOEXT, com_legacyprotocol->integer); Com_sprintf(name, sizeof(name), "demos/%s.%s%d", demoName, DEMOEXT, com_legacyprotocol->integer);