[xiph-cvs] cvs commit: vorbis-python/src pyvorbisinfo.c vorbismodule.c

Andrew Catham Master of Python andrew at xiph.org
Tue May 21 14:43:14 PDT 2002



andrew      02/05/21 14:43:14

  Modified:    .        ChangeLog
               src      pyvorbisinfo.c vorbismodule.c
  Log:
  Fix for crash when comments are not valid UTF-8

Revision  Changes    Path
1.13      +5 -0      vorbis-python/ChangeLog

Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/ChangeLog,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ChangeLog	2002/02/18 01:16:34	1.12
+++ ChangeLog	2002/05/21 21:43:13	1.13
@@ -1,3 +1,8 @@
+2002-05-21  Andrew H. Chatham <andrew.chatham at duke.edu>
+	* pyvorbisinfo.c: Don't crash if comments are not valid UTF-8
+
+	* vorbismodule.c: Include some more headers
+	
 2002-02-17  Andrew H. Chatham <andrew.chatham at duke.edu>
         * pyvorbisfile.c: (py_ov_open): Fixed fd leak pointed out by
         Harald Meland. Also correctly incref file objects passed in to

<p><p>1.9       +11 -1     vorbis-python/src/pyvorbisinfo.c

Index: pyvorbisinfo.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/src/pyvorbisinfo.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- pyvorbisinfo.c	2002/02/18 01:16:34	1.8
+++ pyvorbisinfo.c	2002/05/21 21:43:14	1.9
@@ -427,6 +427,10 @@
     int vallen = strlen(res);
 #if PY_UNICODE
     item = PyUnicode_DecodeUTF8(res, vallen, NULL);
+    if (!item) {
+      /* To deal with non-UTF8 comments (against the standard) */
+      item = PyString_FromStringAndSize(res, vallen); 
+    }
 #else
     item = PyString_FromStringAndSize(res, vallen);
 #endif
@@ -560,9 +564,11 @@
   if (!PyArg_ParseTuple(args, ""))
     return NULL;
 
-  retlist = PyList_New(0);
   dict = py_comment_as_dict(self, NULL);
+  if (!dict)
+    return NULL;
 
+  retlist = PyList_New(0);
   curitem = curpos = 0;
 
   while (PyDict_Next(dict, &curitem, &key, &val) > 0) {
@@ -727,6 +733,10 @@
       
 #if PY_UNICODE
       item = PyUnicode_DecodeUTF8(val, vallen, NULL);
+      if (!item) {
+        /* To deal with non-UTF8 comments (against the standard) */
+        item = PyString_FromStringAndSize(val, vallen); 
+      } 
 #else
       item = PyString_FromStringAndSize(val, vallen);
 #endif

<p><p>1.3       +5 -0      vorbis-python/src/vorbismodule.c

Index: vorbismodule.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/src/vorbismodule.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vorbismodule.c	2002/02/18 01:16:34	1.2
+++ vorbismodule.c	2002/05/21 21:43:14	1.3
@@ -2,6 +2,11 @@
 #include <stdio.h>
 
 #include "vorbismodule.h"
+
+#include "pyvorbiscodec.h"
+#include "pyvorbisfile.h"
+#include "pyvorbisinfo.h"
+
 #include "general.h"
 
 static PyMethodDef Vorbis_methods[] = {

<p><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