Fix for correct cleanup on read error.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 31 Jul 2002 04:18:58 +0000
changeset 446 e1f7fe003b70
parent 445 4990d05454e2
child 447 305273988630
Fix for correct cleanup on read error.
archivers/zip.c
--- a/archivers/zip.c	Tue Jul 30 06:40:20 2002 +0000
+++ b/archivers/zip.c	Wed Jul 31 04:18:58 2002 +0000
@@ -492,7 +492,7 @@
 static int ZIP_isArchive(const char *filename, int forWriting)
 {
     PHYSFS_uint32 sig;
-    int retval;
+    int retval = 0;
     void *in;
 
     in = __PHYSFS_platformOpenRead(filename);
@@ -502,16 +502,18 @@
      * The first thing in a zip file might be the signature of the
      *  first local file record, so it makes for a quick determination.
      */
-    BAIL_IF_MACRO(!readui32(in, &sig), NULL, 0);
-    retval = (sig == ZIP_LOCAL_FILE_SIG);
-    if (!retval)
+    if (readui32(in, &sig))
     {
-        /*
-         * No sig...might be a ZIP with data at the start
-         *  (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);
+        retval = (sig == ZIP_LOCAL_FILE_SIG);
+        if (!retval)
+        {
+            /*
+             * No sig...might be a ZIP with data at the start
+             *  (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 */
 
     __PHYSFS_platformClose(in);