[alsa-devel] [PATCH] [ALSA][UCM] fix memory leak when executing cset commands. snd_ctl_elem's are allocated, but never free'ed

baeksan at ccrma.stanford.edu baeksan at ccrma.stanford.edu
Tue May 3 19:52:34 CEST 2011


From: Baek Chang <breakchange at gmail.com>

---
 src/ucm/main.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/ucm/main.c b/src/ucm/main.c
index 86f29e3..f8ceeeb 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -173,7 +173,8 @@ static int execute_cset(snd_ctl_t *ctl, char *cset)
 	pos = strrchr(cset, ' ');
 	if (pos == NULL) {
 		uc_error("undefined value for cset >%s<", cset);
-		return -EINVAL;
+		err =  -EINVAL;
+		goto __fail;
 	}
 	*pos = '\0';
 	err = snd_ctl_ascii_elem_id_parse(id, cset);
@@ -196,6 +197,14 @@ static int execute_cset(snd_ctl_t *ctl, char *cset)
 	err = 0;
       __fail:
 	*pos = ' ';
+
+	if (id != NULL)
+		free(id);
+	if (value != NULL)
+		free(value);
+	if (info != NULL)
+		free(info);
+
 	return err;
 }
 
-- 
1.6.0.4



More information about the Alsa-devel mailing list