re PR java/30454 (empty "zip" file in class path can cause leakage of file streams)
authorAndrew Pinski <pinskia@gmail.com>
Wed, 24 Jan 2007 05:46:09 +0000 (21:46 -0800)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Wed, 24 Jan 2007 05:46:09 +0000 (21:46 -0800)
2007-01-23  Andrew Pinski  <pinskia@gmail.com>

PR java/30454
* jcf-io.c (opendir_in_zip): Close the file
and free zipf before returning after an error.

From-SVN: r121101

gcc/java/ChangeLog
gcc/java/jcf-io.c

index b26cba7..3702984 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-23  Andrew Pinski  <pinskia@gmail.com>
+
+       PR java/30454
+       * jcf-io.c (opendir_in_zip): Close the file
+       and free zipf before returning after an error.
+
 2007-01-16  Tom Tromey  <tromey@redhat.com>
 
        * java-tree.def: Added copyright header.
index 27b9103..0c9b07b 100644 (file)
@@ -134,10 +134,18 @@ opendir_in_zip (const char *zipfile, int is_system)
     {
       jcf_dependency_add_file (zipfile, is_system);
       if (read (fd, magic, 4) != 4 || GET_u4 (magic) != (JCF_u4)ZIPMAGIC)
-       return NULL;
+       {
+         free (zipf);
+         close (fd);
+         return NULL;
+       }
       lseek (fd, 0L, SEEK_SET);
       if (read_zip_archive (zipf) != 0)
-       return NULL;
+       {
+         free (zipf);
+         close (fd);
+         return NULL;
+       }
     }
 
   SeenZipFiles = zipf;