Fix memory leaks in PCM.write() error paths on python3

This commit is contained in:
Lars Immisch
2023-08-31 16:25:42 +02:00
committed by Oswald Buddenhagen
parent bdca4dc061
commit 07ac637b1c
+9
View File
@@ -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;
}