From cc588c1d37448895f8f98b424c0e51b23c0ae783 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 4 Jul 2010 10:15:11 +0000 Subject: [PATCH] Fix refleak in Modules/audioop.c. --- Modules/audioop.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/audioop.c b/Modules/audioop.c index 66f1f1f36a7..38e3e7ace2f 100644 --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -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);