From 985df9fad73cd9e9c5f18e18f3fe41e030f63b20 Mon Sep 17 00:00:00 2001 From: Thierry Bultel Date: Thu, 20 Dec 2018 22:30:23 +0100 Subject: alsaSetGetCtls: fixed a memory leak By reading the sources of libasound, snd_ctl_elem_list_alloc_space needs a snd_ctl_elem_list_free_space to free the allocated memory Change-Id: I47280fa95c5a47a993c399329aaf655f8c83dd2a Signed-off-by: Thierry Bultel --- alsa-binding/Alsa-SetGet.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'alsa-binding/Alsa-SetGet.c') diff --git a/alsa-binding/Alsa-SetGet.c b/alsa-binding/Alsa-SetGet.c index b0b8949..29c82b3 100644 --- a/alsa-binding/Alsa-SetGet.c +++ b/alsa-binding/Alsa-SetGet.c @@ -767,7 +767,7 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req_t request) { if ((err = snd_ctl_elem_list(ctlDev, ctlList)) < 0) { afb_req_fail_f(request, "listOpen-failed", "devid='%s' load fail error=%s\n", queryValues.devid, snd_strerror(err)); - goto OnErrorExit; + goto fail_space; } // Parse numids string (empty == all) @@ -869,9 +869,12 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req_t request) { // send response+warning if any afb_req_success(request, sndctls, warmsg); - snd_ctl_elem_list_clear(ctlList); + // use OnErrorExit +fail_space: + snd_ctl_elem_list_free_space(ctlList); + snd_ctl_elem_list_clear(ctlList); OnErrorExit: if (ctlDev) snd_ctl_close(ctlDev); return; -- cgit 1.2.3-korg