From 866af7359cfbbaa6215190565dcd58222ca441d1 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Oct 2009 08:46:53 +0200 Subject: [PATCH] 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 --- pyalsa/alsahcontrol.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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; -- 2.47.1