From 07ac637b1c303de1c4c355eb2ec733009fb12f17 Mon Sep 17 00:00:00 2001 From: Lars Immisch Date: Thu, 31 Aug 2023 16:25:42 +0200 Subject: [PATCH] Fix memory leaks in PCM.write() error paths on python3 --- alsaaudio.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/alsaaudio.c b/alsaaudio.c index 1328b90..0e2c168 100644 --- a/alsaaudio.c +++ b/alsaaudio.c @@ -1445,6 +1445,11 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args) if (!self->handle) { PyErr_SetString(ALSAAudioError, "PCM device is closed"); + +#if PY_MAJOR_VERSION >= 3 + PyBuffer_Release(&buf); +#endif + return NULL; } @@ -1452,6 +1457,10 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args) { PyErr_SetString(ALSAAudioError, "Data size must be a multiple of framesize"); + +#if PY_MAJOR_VERSION >= 3 + PyBuffer_Release(&buf); +#endif return NULL; }