Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3bbeb7a

Browse files
committed
Fix by Sjoerd: don't want to resize to zero length.
1 parent 03be7f5 commit 3bbeb7a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Modules/audioop.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,13 @@ audioop_ratecv(self, args)
10391039
cur_i[chan]));
10401040
if (PyErr_Occurred())
10411041
return NULL;
1042-
if (_PyString_Resize(&str,
1043-
ncp - PyString_AsString(str)) < 0)
1042+
len = ncp - PyString_AsString(str);
1043+
if (len == 0) {
1044+
/*don't want to resize to zero length*/
1045+
rv = PyString_FromStringAndSize("", 0);
1046+
Py_DECREF(str);
1047+
str = rv;
1048+
} else if (_PyString_Resize(&str, len) < 0)
10441049
return NULL;
10451050
rv = Py_BuildValue("(O(iO))", str, d, samps);
10461051
Py_DECREF(samps);

0 commit comments

Comments
 (0)