[PATCH 1/1] alsabat: fix a possible memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Lu, Han" <han.lu@xxxxxxxxx>

Fix a possible memory leak in generate_sine_wave(). Memory free was
ignored when the function return an error.

Signed-off-by: Lu, Han <han.lu@xxxxxxxxx>

diff --git a/bat/signal.c b/bat/signal.c
index a47ba97..61d2824 100644
--- a/bat/signal.c
+++ b/bat/signal.c
@@ -168,16 +168,17 @@ int generate_sine_wave(struct bat *bat, int frames, void *buf)
 	/* reorder samples to interleaved mode */
 	err = reorder(bat, sinus_f, frames);
 	if (err != 0)
-		return err;
+		goto exit;
 
 	/* adjust amplitude and offset of waveform */
 	err = adjust_waveform(bat, sinus_f, frames);
 	if (err != 0)
-		return err;
+		goto exit;
 
 	bat->convert_float_to_sample(sinus_f, buf, frames, bat->channels);
 
+exit:
 	free(sinus_f);
 
-	return 0;
+	return err;
 }
-- 
2.5.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux