[svn:parrot] r36642 - trunk/src

chromatic at svn.parrot.org chromatic at svn.parrot.org
Thu Feb 12 20:58:46 UTC 2009


Author: chromatic
Date: Thu Feb 12 20:58:45 2009
New Revision: 36642
URL: https://trac.parrot.org/parrot/changeset/36642

Log:
[src] Added an explicit close of packfile file if reading fails, so as not to
leak file descriptors.

Modified:
   trunk/src/embed.c

Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c	Thu Feb 12 20:54:53 2009	(r36641)
+++ trunk/src/embed.c	Thu Feb 12 20:58:45 2009	(r36642)
@@ -440,9 +440,9 @@
 #endif
     /* if we've opened a file (or stdin) with PIO, read it in */
     if (io) {
+        char  *cursor;
         size_t chunk_size = program_size > 0 ? program_size : 1024;
         INTVAL wanted     = program_size;
-        char  *cursor;
         size_t read_result;
 
         program_code = (char *)mem_sys_allocate(chunk_size);
@@ -461,6 +461,7 @@
                 Parrot_io_eprintf(interp,
                             "Parrot VM: Could not reallocate buffer "
                             "while reading packfile from PIO.\n");
+                fclose(io);
                 return NULL;
             }
 


More information about the parrot-commits mailing list