]> git.alsa-project.org Git - alsa-python.git/commitdiff
hcontrol: fix memory leak
authorClemens Ladisch <clemens@ladisch.de>
Mon, 12 Oct 2009 06:46:53 +0000 (08:46 +0200)
committerClemens Ladisch <clemens@ladisch.de>
Mon, 12 Oct 2009 06:46:53 +0000 (08:46 +0200)
The pfd array was never freed.  In this function, we can just replace
malloc with alloca.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
pyalsa/alsahcontrol.c

index 68d822884afe3789ab4c9f5aaaafd4af10a47cab..b2db13e66df4e9b1cfdd5891b7018d52b8c5aa2e 100644 (file)
@@ -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;