mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
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*. ........
This commit is contained in:
parent
688356f59f
commit
423be95dcf
32 changed files with 721 additions and 390 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue