]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: fix memory leak when setup_chmap() fail
authorchunxu.li <chunxuxiao@gmail.com>
Sun, 23 Jun 2019 15:54:29 +0000 (23:54 +0800)
committerJaroslav Kysela <perex@perex.cz>
Wed, 25 Sep 2019 07:57:19 +0000 (09:57 +0200)
setup_chmap() will return with error number if hw_map calloc fail or
channels doesn't match with hw_params, but memory free was ignored when
error occurs.

Signed-off-by: chunxu.li <chunxuxiao@gmail.com>
Reviewed-by: Takashi Sakamoto o-takashi@sakamocchi.jp
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
aplay/aplay.c

index 5b3a766e912d1adb8e39c679b7e0976f3a97916b..274bbce33dd2231a1e050cdea48ab373e817ade7 100644 (file)
@@ -1262,6 +1262,7 @@ static int setup_chmap(void)
        hw_map = calloc(hwparams.channels, sizeof(int));
        if (!hw_map) {
                error(_("not enough memory"));
+               free(hw_chmap);
                return -1;
        }
 
@@ -1284,6 +1285,7 @@ static int setup_chmap(void)
                        error(_("Channel %d doesn't match with hw_parmas"), ch);
                        snd_pcm_chmap_print(hw_chmap, sizeof(buf), buf);
                        fprintf(stderr, "hardware chmap = %s\n", buf);
+                       free(hw_chmap);
                        return -1;
                }
        }