[GEM-dev] fixed filehandle leak?

Mathieu Bouchard matju at artengine.ca
Mon Jun 13 23:04:02 CEST 2005


Here's a bug that causes a filehandle leak in GEM. Every time an image 
load is attempted via image2mem() (used by [pix_image], [pix_multiimage], 
etc.) then a series of decoders are called one after the other, quitting 
after the first that succeeds. If the file exists and is not of any 
type handled before the SGI handler and not of SGI type either, the SGI 
decoder does not close the file handle.

This happened several times when loading a *lot* of TIFF images on Windows 
during a Pd/GEM workshop at Videographe, this afternoon. When too many 
files are "open", then PureData can't open any new patch and can't even 
save any modified patches!

Did I get it right?



Index: src/Base/sgiimage.cpp
===================================================================
RCS file: /cvsroot/pd-gem/Gem/src/Base/sgiimage.cpp,v
retrieving revision 1.5
diff -u -r1.5 sgiimage.cpp
--- src/Base/sgiimage.cpp       14 Sep 2003 16:03:59 -0000      1.5
+++ src/Base/sgiimage.cpp       13 Jun 2005 20:57:05 -0000
@@ -248,6 +248,7 @@
      if(image.imagic != IMAGIC)
         {
                 /* fprintf(stderr,"sizeofimage: bad magic number in image 
file\n"); */
+               fclose(inf);
                 return(0);
      }
      *xsize = image.xsize;

,-o--------o--------o--------o-. ,---. irc.freenode.net #dataflow |
| The Diagram is the Program tm| | ,-o-------------o--------------o-.
`-o------------o-------------o-' | | Mathieu Bouchard (Montréal QC) |
   | téléphone:+1.514.383.3801`---' `-o-- http://artengine.ca/matju -'


More information about the GEM-dev mailing list