From 74ff891914c7f91b0f6c86a7a075a4fafdaf15e5 Mon Sep 17 00:00:00 2001 From: "M. Kristall" Date: Sat, 3 Oct 2009 11:41:43 +0000 Subject: * Fix a couple more places where files might not be closed (bug 3554) * Fix off-by-one errors and some gcc warnings --- src/cgame/cg_ptr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/cgame/cg_ptr.c') diff --git a/src/cgame/cg_ptr.c b/src/cgame/cg_ptr.c index 18810878..b5fa548e 100644 --- a/src/cgame/cg_ptr.c +++ b/src/cgame/cg_ptr.c @@ -42,12 +42,15 @@ int CG_ReadPTRCode( void ) // load the file len = trap_FS_FOpenFile( PTRC_FILE, &f, FS_READ ); - if( len <= 0 ) + if( len < 0 ) return 0; // should never happen - malformed write - if( len >= sizeof( text ) - 1 ) + if( len == 0 || len >= sizeof( text ) - 1 ) + { + trap_FS_FCloseFile( f ); return 0; + } trap_FS_Read( text, len, f ); text[ len ] = 0; -- cgit