[xiph-cvs] cvs commit: vorbis-python/src pyvorbisfile.c pyvorbisfile.h

Andrew Chatham Master of Python andrew at xiph.org
Mon Sep 1 16:30:26 PDT 2003



andrew      03/09/01 19:30:26

  Modified:    .        ChangeLog
               src      pyvorbisfile.c pyvorbisfile.h
  Log:
  2003-9-01   Andrew H. Chatham <pyogg at andrewchatham.com>
          * pyvorbisfile.c (py_ov_file_dealloc) Fix a file descriptor leak.

Revision  Changes    Path
1.23      +3 -0      vorbis-python/ChangeLog

Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/ChangeLog,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ChangeLog	31 May 2003 19:41:13 -0000	1.22
+++ ChangeLog	1 Sep 2003 23:30:26 -0000	1.23
@@ -1,3 +1,6 @@
+2003-9-01   Andrew H. Chatham <pyogg at andrewchatham.com>
+	* pyvorbisfile.c (py_ov_file_dealloc) Fix a file descriptor leak.
+	
 2003-5-31   Andrew H. Chatham <pyogg at andrewchatham.com>
         * pyvorbisinfo.c (py_comment_subscript) Applied patch from Brian
         Warner to fix a bug where I wasn't clearing the Python error

<p><p>1.12      +15 -3     vorbis-python/src/pyvorbisfile.c

Index: pyvorbisfile.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/src/pyvorbisfile.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- pyvorbisfile.c	14 May 2003 07:55:54 -0000	1.11
+++ pyvorbisfile.c	1 Sep 2003 23:30:26 -0000	1.12
@@ -181,8 +181,15 @@
   if (PY_VORBISFILE(self))
     ov_clear(PY_VORBISFILE(self));
 
-  /* If file was opened from a file object, decref it, so it can close */
-  Py_XDECREF(((py_vorbisfile *) self)->py_file);
+  py_vorbisfile *py_self = (py_vorbisfile *) self;
+  if (py_self->py_file) {
+    /* If file was opened from a file object, decref it, so it can
+       close */
+    Py_DECREF(py_self->py_file);
+  } else {
+    /* Otherwise, we opened the file and should close it. */
+    fclose(py_self->c_file);
+  }
 
   PyMem_DEL(self);
 }
@@ -248,6 +255,7 @@
   
   retval = ov_open(file, self->ovf, initial, ibytes);
 
+  self->c_file = file;
   if (retval < 0) {
     if (fname != NULL)
       fclose(file);
@@ -261,7 +269,11 @@
 
 }
 
-static char *read_kwlist[] = {"length", "bigendian", "word", "signed", NULL};
+static char *read_kwlist[] = {"length", 
+			      "bigendian", 
+			      "word", 
+			      "signed", 
+			      NULL};
 
 static int is_big_endian() {
   static int x = 0x1;

<p><p>1.6       +1 -0      vorbis-python/src/pyvorbisfile.h

Index: pyvorbisfile.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/src/pyvorbisfile.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- pyvorbisfile.h	17 Jul 2002 05:04:40 -0000	1.5
+++ pyvorbisfile.h	1 Sep 2003 23:30:26 -0000	1.6
@@ -8,6 +8,7 @@
   PyObject_HEAD
   OggVorbis_File *ovf;
   PyObject *py_file;
+  FILE *c_file;
 } py_vorbisfile;
 
 #define PY_VORBISFILE(x) (((py_vorbisfile *)x)->ovf)

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list