mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:25:42 +01:00
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 <chunxuxiao@gmail.com> Reviewed-by: Takashi Sakamoto o-takashi@sakamocchi.jp Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
192fb6220a
commit
d40e724905
1 changed files with 2 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue