]> git.alsa-project.org Git - alsa-lib.git/commitdiff
UCM: fix memory leak when executing cset commands
authorBaek Chang <breakchange@gmail.com>
Tue, 3 May 2011 17:52:34 +0000 (10:52 -0700)
committerTakashi Iwai <tiwai@suse.de>
Wed, 4 May 2011 07:21:34 +0000 (09:21 +0200)
fix memory leak when executing cset commands.
snd_ctl_elem's are allocated, but never free'ed

Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/ucm/main.c

index 86f29e332388120fc3fa70f3c25524a58e8266cb..f8ceeebde69ca0745cf798152449808390856736 100644 (file)
@@ -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;
 }