From: Clemens Ladisch Date: Mon, 12 Oct 2009 06:46:53 +0000 (+0200) Subject: hcontrol: fix memory leak X-Git-Tag: v1.0.22~4 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=866af7359cfbbaa6215190565dcd58222ca441d1;p=alsa-python.git hcontrol: fix memory leak The pfd array was never freed. In this function, we can just replace malloc with alloca. Signed-off-by: Clemens Ladisch --- diff --git a/pyalsa/alsahcontrol.c b/pyalsa/alsahcontrol.c index 68d8228..b2db13e 100644 --- a/pyalsa/alsahcontrol.c +++ b/pyalsa/alsahcontrol.c @@ -175,9 +175,7 @@ pyalsahcontrol_registerpoll(struct pyalsahcontrol *self, PyObject *args) count = snd_hctl_poll_descriptors_count(self->handle); if (count <= 0) Py_RETURN_NONE; - pfd = malloc(sizeof(struct pollfd) * count); - if (pfd == NULL) - Py_RETURN_NONE; + pfd = alloca(sizeof(struct pollfd) * count); count = snd_hctl_poll_descriptors(self->handle, pfd, count); if (count <= 0) Py_RETURN_NONE;