summaryrefslogtreecommitdiff
path: root/src/cgame/cg_ptr.c
diff options
context:
space:
mode:
authorM. Kristall <mkpdev@gmail.com>2009-10-03 11:41:43 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:14 +0000
commit74ff891914c7f91b0f6c86a7a075a4fafdaf15e5 (patch)
treef415232f36f56a673d29bd7a06577be14f2e9fc5 /src/cgame/cg_ptr.c
parent614a658030e59212335611596adb196b93e5b437 (diff)
* Fix a couple more places where files might not be closed (bug 3554)
* Fix off-by-one errors and some gcc warnings
Diffstat (limited to 'src/cgame/cg_ptr.c')
-rw-r--r--src/cgame/cg_ptr.c7
1 files changed, 5 insertions, 2 deletions
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;