shithub: aacenc

Download patch

ref: 1664484e81aa123b419319e5f8f69c999f66274b
parent: f3ce26d5f169d441b0a3a120c8bd8d70e0261b33
author: menno <menno>
date: Thu Feb 1 15:22:47 EST 2001

Fixed memory leakage

--- a/libfaac/frame.c
+++ b/libfaac/frame.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.c,v 1.4 2001/01/31 23:40:05 menno Exp $
+ * $Id: frame.c,v 1.5 2001/02/01 20:22:47 menno Exp $
  */
 
 /*
@@ -111,6 +111,8 @@
 
 int FAACAPI faacEncClose(faacEncHandle hEncoder)
 {
+	unsigned int channel;
+
 	/* Deinitialize coder functions */
 	PsyEnd(&hEncoder->gpsyInfo, hEncoder->psyInfo, hEncoder->numChannels);
 
@@ -119,6 +121,12 @@
 	AACQuantizeEnd();
 
 	HuffmanEnd(hEncoder->coderInfo, hEncoder->numChannels);
+
+	/* Free remaining buffer memory */
+	for (channel = 0; channel < hEncoder->numChannels; channel++) {
+		if (hEncoder->sampleBuff[channel]) free(hEncoder->sampleBuff[channel]);
+		if (hEncoder->nextSampleBuff[channel]) free(hEncoder->nextSampleBuff[channel]);
+	}
 
 	/* Free handle */
 	if (hEncoder) free(hEncoder);
--- a/libfaac/psych.c
+++ b/libfaac/psych.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: psych.c,v 1.3 2001/01/31 23:40:05 menno Exp $
+ * $Id: psych.c,v 1.4 2001/02/01 20:22:47 menno Exp $
  */
 
 #include <stdlib.h>
@@ -281,6 +281,7 @@
 	if (gpsyInfo->windowS) free(gpsyInfo->windowS);
 
 	for (channel = 0; channel < numChannels; channel++) {
+		if (psyInfo[channel].nb) free(psyInfo[channel].nb);
 		if (psyInfo[channel].tonality) free(psyInfo[channel].tonality);
 		if (psyInfo[channel].prevSamples) free(psyInfo[channel].prevSamples);
 		if (psyInfo[channel].maskThr) free(psyInfo[channel].maskThr);
@@ -303,6 +304,7 @@
 	for (channel = 0; channel < numChannels; channel++) {
 		if(psyInfo[channel].prevSamplesS) free(psyInfo[channel].prevSamplesS);
 		for (j = 0; j < 8; j++) {
+			if (psyInfo[channel].nbS[j]) free(psyInfo[channel].nbS[j]);
 			if (psyInfo[channel].maskThrS[j]) free(psyInfo[channel].maskThrS[j]);
 			if (psyInfo[channel].maskEnS[j]) free(psyInfo[channel].maskEnS[j]);
 			if (psyInfo[channel].maskThrNextS[j]) free(psyInfo[channel].maskThrNextS[j]);