]> granicus.if.org Git - python/commitdiff
Fix by Sjoerd: don't want to resize to zero length.
authorGuido van Rossum <guido@python.org>
Mon, 22 Sep 1997 16:14:27 +0000 (16:14 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 22 Sep 1997 16:14:27 +0000 (16:14 +0000)
Modules/audioop.c

index 471f851fa2aae8581cffd02dbc4ff53bf025a431..fc33bcd1a5e5c9ed5706dccec2b0d0a4566f5b7a 100644 (file)
@@ -1039,8 +1039,13 @@ audioop_ratecv(self, args)
                                                              cur_i[chan]));
                                if (PyErr_Occurred())
                                        return NULL;
-                               if (_PyString_Resize(&str,
-                                       ncp - PyString_AsString(str)) < 0)
+                               len = ncp - PyString_AsString(str);
+                               if (len == 0) {
+                                       /*don't want to resize to zero length*/
+                                       rv = PyString_FromStringAndSize("", 0);
+                                       Py_DECREF(str);
+                                       str = rv;
+                               } else if (_PyString_Resize(&str, len) < 0)
                                        return NULL;
                                rv = Py_BuildValue("(O(iO))", str, d, samps);
                                Py_DECREF(samps);