Fix refleak in Modules/audioop.c.

This commit is contained in:
Mark Dickinson 2010-07-04 10:15:11 +00:00
parent be7a7553cd
commit cc588c1d37
1 changed files with 7 additions and 2 deletions

View File

@ -807,10 +807,13 @@ audioop_tomono(PyObject *self, PyObject *args)
return 0;
cp = pcp.buf;
len = pcp.len;
if (!audioop_check_parameters(len, size))
if (!audioop_check_parameters(len, size)) {
PyBuffer_Release(&pcp);
return NULL;
}
if (((len / size) & 1) != 0) {
PyErr_SetString(AudioopError, "not a whole number of frames");
PyBuffer_Release(&pcp);
return NULL;
}
@ -824,8 +827,10 @@ audioop_tomono(PyObject *self, PyObject *args)
}
rv = PyBytes_FromStringAndSize(NULL, len/2);
if ( rv == 0 )
if ( rv == 0 ) {
PyBuffer_Release(&pcp);
return 0;
}
ncp = (signed char *)PyBytes_AsString(rv);