Skip to contentSkip to conversation

src/pcm/pcm_rate.c: add missing free

PATCH In review Julia Lawall 2 participants 3 messages Sep 18, 2011 – Sep 22, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 src/pcm/pcm_rate.c: add missing free

From: Julia Lawall <[email protected]>

Something that is allocated using calloc is not freed on one or more error paths.

---
Compile-tested only.

 src/pcm/pcm_rate.c |    4 ++++
 1 file changed, 4 insertions(+)
src/pcm/pcm_rate.c +4 -0
index 70e30e5..eb35e4a 100644
@@ -1392,11 +1392,13 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	} else {
 		SNDERR("Invalid type for rate converter");
 		snd_pcm_close(pcm);
+		free(rate);
 		return -EINVAL;
 	}
 	if (err < 0) {
 		SNDERR("Cannot find rate converter");
 		snd_pcm_close(pcm);
+		free(rate);
 		return -ENOENT;
 	}
 #else
@@ -1405,6 +1407,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops);
 	if (err < 0) {
 		snd_pcm_close(pcm);
+		free(rate);
 		return err;
 	}
 #endif
@@ -1413,6 +1416,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	    ! rate->ops.input_frames || ! rate->ops.output_frames) {
 		SNDERR("Inproper rate plugin %s initialization", type);
 		snd_pcm_close(pcm);
+		free(rate);
 		return err;
 	}
 
#1 lore raw

At Sun, 18 Sep 2011 22:04:34 +0200,

Quoted 8 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Something that is allocated using calloc is not freed on one or more error paths.

Thanks, now applied patches 1, 3 and 4.
(2 needs a rewrite.)

Takashi

Quoted 47 lines

---
Compile-tested only.

 src/pcm/pcm_rate.c |    4 ++++
 1 file changed, 4 insertions(+)
src/pcm/pcm_rate.c +4 -0
index 70e30e5..eb35e4a 100644
@@ -1392,11 +1392,13 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	} else {
 		SNDERR("Invalid type for rate converter");
 		snd_pcm_close(pcm);
+		free(rate);
 		return -EINVAL;
 	}
 	if (err < 0) {
 		SNDERR("Cannot find rate converter");
 		snd_pcm_close(pcm);
+		free(rate);
 		return -ENOENT;
 	}
 #else
@@ -1405,6 +1407,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops);
 	if (err < 0) {
 		snd_pcm_close(pcm);
+		free(rate);
 		return err;
 	}
 #endif
@@ -1413,6 +1416,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	    ! rate->ops.input_frames || ! rate->ops.output_frames) {
 		SNDERR("Inproper rate plugin %s initialization", type);
 		snd_pcm_close(pcm);
+		free(rate);
 		return err;
 	}
 

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw
Quoted 5 lines · Takashi Iwai

At Sun, 18 Sep 2011 22:04:34 +0200,

Quoted 3 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Quoted 8 lines
Quoted 5 lines

Something that is allocated using calloc is not freed on one or more error paths.

Thanks, now applied patches 1, 3 and 4.
(2 needs a rewrite.)

Thanks for the feedback on 2. I will take care of it shortly.

julia

Quoted 56 lines

Takashi

Quoted 42 lines

---
Compile-tested only.

 src/pcm/pcm_rate.c |    4 ++++
 1 file changed, 4 insertions(+)
src/pcm/pcm_rate.c +4 -0
index 70e30e5..eb35e4a 100644
@@ -1392,11 +1392,13 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	} else {
 		SNDERR("Invalid type for rate converter");
 		snd_pcm_close(pcm);
+		free(rate);
 		return -EINVAL;
 	}
 	if (err < 0) {
 		SNDERR("Cannot find rate converter");
 		snd_pcm_close(pcm);
+		free(rate);
 		return -ENOENT;
 	}
 #else
@@ -1405,6 +1407,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops);
 	if (err < 0) {
 		snd_pcm_close(pcm);
+		free(rate);
 		return err;
 	}
 #endif
@@ -1413,6 +1416,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
 	    ! rate->ops.input_frames || ! rate->ops.output_frames) {
 		SNDERR("Inproper rate plugin %s initialization", type);
 		snd_pcm_close(pcm);
+		free(rate);
 		return err;
 	}
 
Quoted 5 lines

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel