From: chunxu.li Date: Sun, 23 Jun 2019 15:54:29 +0000 (+0800) Subject: aplay: fix memory leak when setup_chmap() fail X-Git-Tag: v1.2.1~12 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=d40e72490541c5caa567741f72d0f78ddfb082c0;p=alsa-utils.git aplay: fix memory leak when setup_chmap() fail 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 Reviewed-by: Takashi Sakamoto o-takashi@sakamocchi.jp Signed-off-by: Jaroslav Kysela --- diff --git a/aplay/aplay.c b/aplay/aplay.c index 5b3a766..274bbce 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -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; } }