Fix for correct cleanup on read error.

This commit is contained in:
Ryan C. Gordon 2002-07-31 04:18:58 +00:00
parent 8793165653
commit 912ca3266d
1 changed files with 12 additions and 10 deletions

View File

@ -492,7 +492,7 @@ static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
static int ZIP_isArchive(const char *filename, int forWriting) static int ZIP_isArchive(const char *filename, int forWriting)
{ {
PHYSFS_uint32 sig; PHYSFS_uint32 sig;
int retval; int retval = 0;
void *in; void *in;
in = __PHYSFS_platformOpenRead(filename); in = __PHYSFS_platformOpenRead(filename);
@ -502,16 +502,18 @@ static int ZIP_isArchive(const char *filename, int forWriting)
* The first thing in a zip file might be the signature of the * The first thing in a zip file might be the signature of the
* first local file record, so it makes for a quick determination. * first local file record, so it makes for a quick determination.
*/ */
BAIL_IF_MACRO(!readui32(in, &sig), NULL, 0); if (readui32(in, &sig))
retval = (sig == ZIP_LOCAL_FILE_SIG);
if (!retval)
{ {
/* retval = (sig == ZIP_LOCAL_FILE_SIG);
* No sig...might be a ZIP with data at the start if (!retval)
* (a self-extracting executable, etc), so we'll have to do {
* it the hard way... /*
*/ * No sig...might be a ZIP with data at the start
retval = (zip_find_end_of_central_dir(in, NULL) != -1); * (a self-extracting executable, etc), so we'll have to do
* it the hard way...
*/
retval = (zip_find_end_of_central_dir(in, NULL) != -1);
} /* if */
} /* if */ } /* if */
__PHYSFS_platformClose(in); __PHYSFS_platformClose(in);