This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [java/PATCH] PR 30454 Fix bootstrap on a couple of targets, empty "zip" file in class path can cause leakage of file streams


On Tue, 2007-01-23 at 08:40 -0700, Tom Tromey wrote:
> >>>>> "Andrew" == Andrew Pinski <pinskia@gmail.com> writes:
> 
> Andrew> The problem here is that empty "zip" files in the classpath
> Andrew> would cause leakage of file streams which meant after a while,
> Andrew> we hit the limit of opened files.
> 
> Nice catch, thanks.
> 
> Andrew> OK?
> 
> I think we should free 'zipf' in the 'return NULL' cases.
> Ok with that change.

And this is what I applied.

Thanks,
Andrew Pinski

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.


Index: java/ChangeLog
===================================================================
--- java/ChangeLog	(revision 121100)
+++ java/ChangeLog	(working copy)
@@ -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: java/jcf-io.c
===================================================================
--- java/jcf-io.c	(revision 121081)
+++ java/jcf-io.c	(working copy)
@@ -134,10 +134,18 @@ opendir_in_zip (const char *zipfile, int
     {
       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;  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]