host_cmd.c (Host_Loadgame_f): Close the file before signalling an error

(noticed this in recent RMQ sources.)

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@518 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2011-12-15 06:31:51 +00:00
parent 8625074bb4
commit abd0089b8a

View file

@ -1158,6 +1158,7 @@ void Host_Loadgame_f (void)
if (!sv.active) if (!sv.active)
{ {
fclose (f);
Con_Printf ("Couldn't load map\n"); Con_Printf ("Couldn't load map\n");
return; return;
} }
@ -1189,14 +1190,20 @@ void Host_Loadgame_f (void)
} }
} }
if (i == sizeof(str) - 1) if (i == sizeof(str) - 1)
{
fclose (f);
Sys_Error ("Loadgame buffer overflow"); Sys_Error ("Loadgame buffer overflow");
}
str[i] = 0; str[i] = 0;
start = str; start = str;
start = COM_Parse(str); start = COM_Parse(str);
if (!com_token[0]) if (!com_token[0])
break; // end of file break; // end of file
if (strcmp(com_token,"{")) if (strcmp(com_token,"{"))
{
fclose (f);
Sys_Error ("First token isn't a brace"); Sys_Error ("First token isn't a brace");
}
if (entnum == -1) if (entnum == -1)
{ // parse the global vars { // parse the global vars