src/pcm/pcm_mmap.c: add missing free
PATCH 2/4 src/pcm/pcm_mmap.c: add missing free
From: Julia Lawall <[email protected]>
Something that is allocated using calloc is not freed on an error path.
---
Compile-tested only.
src/pcm/pcm_mmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
src/pcm/pcm_mmap.c +4 -1
@@ -320,8 +320,11 @@ int snd_pcm_mmap(snd_pcm_t *pcm)snd_pcm_channel_info_t *i = &pcm->mmap_channels[c]; i->channel = c; err =snd_pcm_channel_info (pcm, i); -if (err <0 ) +if (err <0 ) { +free (pcm->mmap_channels); + pcm->mmap_channels =NULL ;return err; + } }for (c =0 ; c < pcm->channels; ++c) {snd_pcm_channel_info_t *i = &pcm->mmap_channels[c];
At Sun, 18 Sep 2011 22:04:35 +0200,
Quoted 19 lines · Julia Lawall
From: Julia Lawall <[email protected]>
Something that is allocated using calloc is not freed on an error path.
Signed-off-by Julia Lawall <[email protected]>Signed-off-by Suman Saha <[email protected]>---
Compile-tested only.src/pcm/pcm_mmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)src/pcm/pcm_mmap.c +0
-0
src/pcm/pcm_mmap.c int snd_pcm_mmap(snd_pcm_t *pcm) · line 325
Quoted 7 lines
src/pcm/pcm_mmap.c +3
-1@@ -320,8 +320,11 @@ int snd_pcm_mmap(snd_pcm_t *pcm)snd_pcm_channel_info_t *i = &pcm->mmap_channels[c]; i->channel = c; err =snd_pcm_channel_info (pcm, i); -if (err <0 ) +if (err <0 ) { +free (pcm->mmap_channels); + pcm->mmap_channels =NULL ;
pcm->running_areas should be freed here, too.
thanks,
Takashi
From: Julia Lawall <[email protected]>
The mmap_channels and running_areas fields are allocated using calloc, but are not freed on an error path.
---
Compile-tested only.
src/pcm/pcm_mmap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
src/pcm/pcm_mmap.c +6 -1
@@ -320,8 +320,13 @@ int snd_pcm_mmap(snd_pcm_t *pcm)snd_pcm_channel_info_t *i = &pcm->mmap_channels[c]; i->channel = c; err =snd_pcm_channel_info (pcm, i); -if (err <0 ) +if (err <0 ) { +free (pcm->mmap_channels); +free (pcm->running_areas); + pcm->mmap_channels =NULL ; + pcm->running_areas =NULL ;return err; + } }for (c =0 ; c < pcm->channels; ++c) {snd_pcm_channel_info_t *i = &pcm->mmap_channels[c];
At Thu, 22 Sep 2011 13:59:31 +0200 (CEST),
Quoted 8 lines · Julia Lawall
From: Julia Lawall <[email protected]>
The
mmap_channelsandrunning_areasfields are allocated using calloc, but are not freed on an error path.Signed-off-by Julia Lawall <[email protected]>Signed-off-by Suman Saha <[email protected]>
Thanks for a quick update.
Applied now.
Takashi
Quoted 27 lines
---
Compile-tested only.src/pcm/pcm_mmap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)src/pcm/pcm_mmap.c +6
-1@@ -320,8 +320,13 @@ int snd_pcm_mmap(snd_pcm_t *pcm)snd_pcm_channel_info_t *i = &pcm->mmap_channels[c]; i->channel = c; err =snd_pcm_channel_info (pcm, i); -if (err <0 ) +if (err <0 ) { +free (pcm->mmap_channels); +free (pcm->running_areas); + pcm->mmap_channels =NULL ; + pcm->running_areas =NULL ;return err; + } }for (c =0 ; c < pcm->channels; ++c) {snd_pcm_channel_info_t *i = &pcm->mmap_channels[c];