From d40e72490541c5caa567741f72d0f78ddfb082c0 Mon Sep 17 00:00:00 2001 From: "chunxu.li" Date: Sun, 23 Jun 2019 23:54:29 +0800 Subject: [PATCH] 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 --- aplay/aplay.c | 2 ++ 1 file changed, 2 insertions(+) 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; } } -- 2.47.1