summaryrefslogtreecommitdiffstats
path: root/Modules/audioop.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-08-13 15:53:07 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-08-13 15:53:07 (GMT)
commit423be95dcf55b0b8737207beb7b30eb549430dba (patch)
treeb23453f2dc43d809aca931203a9580a81bd938fe /Modules/audioop.c
parent688356f59f3b0fe2412a5f66b79f0f9fdc4a98d2 (diff)
downloadcpython-423be95dcf55b0b8737207beb7b30eb549430dba.zip
cpython-423be95dcf55b0b8737207beb7b30eb549430dba.tar.gz
cpython-423be95dcf55b0b8737207beb7b30eb549430dba.tar.bz2
Merged revisions 65654 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r65654 | martin.v.loewis | 2008-08-12 16:49:50 +0200 (Tue, 12 Aug 2008) | 6 lines Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple, by denying s# to parse objects that have a releasebuffer procedure, and introducing s*. More module might need to get converted to use s*. ........
Diffstat (limited to 'Modules/audioop.c')
-rw-r--r--Modules/audioop.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c
index c54e512..b2fdb9a 100644
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -783,20 +783,24 @@ audioop_mul(PyObject *self, PyObject *args)
static PyObject *
audioop_tomono(PyObject *self, PyObject *args)
{
+ Py_buffer pcp;
signed char *cp, *ncp;
int len, size, val1 = 0, val2 = 0;
double fac1, fac2, fval, maxval;
PyObject *rv;
int i;
- if ( !PyArg_ParseTuple(args, "s#idd:tomono",
- &cp, &len, &size, &fac1, &fac2 ) )
+ if ( !PyArg_ParseTuple(args, "s*idd:tomono",
+ &pcp, &size, &fac1, &fac2 ) )
return 0;
+ cp = pcp.buf;
+ len = pcp.len;
if ( size == 1 ) maxval = (double) 0x7f;
else if ( size == 2 ) maxval = (double) 0x7fff;
else if ( size == 4 ) maxval = (double) 0x7fffffff;
else {
+ PyBuffer_Release(&pcp);
PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
return 0;
}
@@ -822,6 +826,7 @@ audioop_tomono(PyObject *self, PyObject *args)
else if ( size == 2 ) *SHORTP(ncp, i/2) = (short)val1;
else if ( size == 4 ) *LONGP(ncp, i/2)= (Py_Int32)val1;
}
+ PyBuffer_Release(&pcp);
return rv;
}