mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
pcm: chmap: Fix memory leak at snd_pcm_set_chmap()
snd_pcm_set_chmap() leaks the memory returned from snd_pcm_get_chmap()
without releasing. Add the missing free() call as well as a slight
code refactoring.
Reported-by: Conrad Jones
BugLink: https://github.com/alsa-project/alsa-lib/pull/11
Fixes: d20e24e5d1 ("chmap: Always succeed setting the map to what it already is")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
1d7a131f78
commit
0732e47e6b
1 changed files with 7 additions and 2 deletions
|
|
@ -8099,8 +8099,13 @@ snd_pcm_chmap_t *snd_pcm_get_chmap(snd_pcm_t *pcm)
|
|||
*/
|
||||
int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map)
|
||||
{
|
||||
const snd_pcm_chmap_t *oldmap = snd_pcm_get_chmap(pcm);
|
||||
if (oldmap && chmap_equal(oldmap, map))
|
||||
const snd_pcm_chmap_t *oldmap;
|
||||
int nochange;
|
||||
|
||||
oldmap = snd_pcm_get_chmap(pcm);
|
||||
nochange = (oldmap && chmap_equal(oldmap, map));
|
||||
free((void *)oldmap);
|
||||
if (nochange)
|
||||
return 0;
|
||||
|
||||
if (!pcm->ops->set_chmap)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue