summaryrefslogtreecommitdiff
path: root/sms/sms.c
diff options
context:
space:
mode:
authorJohn Glover <glover.john@gmail.com>2010-12-09 22:19:17 +0000
committerJohn Glover <glover.john@gmail.com>2010-12-09 22:19:17 +0000
commit5ca314e5ccf3dfb98fdea9d37646baca66d75ec3 (patch)
tree40de39619d48a3cca458254d081d97222dac6dd7 /sms/sms.c
parentb27a8f7182edb2f9e15fd60e78d54fb9fd0c5472 (diff)
downloadsimpl-5ca314e5ccf3dfb98fdea9d37646baca66d75ec3.tar.gz
simpl-5ca314e5ccf3dfb98fdea9d37646baca66d75ec3.tar.bz2
simpl-5ca314e5ccf3dfb98fdea9d37646baca66d75ec3.zip
Fixed bug in SMS peak detection - find_peaks was leaking memory wen saving peaks, and a pointer assignment in find_peaks could lead to a double free in freeAnalysis/freeSpectralPeaks.
Diffstat (limited to 'sms/sms.c')
-rw-r--r--sms/sms.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sms/sms.c b/sms/sms.c
index f9ed932..89bfa9f 100644
--- a/sms/sms.c
+++ b/sms/sms.c
@@ -518,6 +518,17 @@ void sms_freeAnalysis(SMS_AnalParams *pAnalParams)
free(pAnalParams->stocMagSpectrum);
if(pAnalParams->approxEnvelope)
free(pAnalParams->approxEnvelope);
+
+ pAnalParams->pFrames = NULL;
+ pAnalParams->ppFrames = NULL;
+ pAnalParams->soundBuffer.pFBuffer = NULL;
+ pAnalParams->synthBuffer.pFBuffer = NULL;
+ pAnalParams->residual = NULL;
+ pAnalParams->residualWindow = NULL;
+ pAnalParams->guideStates = NULL;
+ pAnalParams->guides = NULL;
+ pAnalParams->stocMagSpectrum = NULL;
+ pAnalParams->approxEnvelope = NULL;
}
/*! \brief free analysis data
@@ -579,8 +590,6 @@ void sms_freeSpectralPeaks(SMS_SpectralPeaks* peaks)
{
if(!peaks)
return;
- if(peaks->nPeaks <= 0)
- return;
if(peaks->pSpectralPeaks)
free(peaks->pSpectralPeaks);
@@ -671,11 +680,11 @@ int sms_clearAnalysisFrame(int iCurrentFrame, SMS_AnalParams *pAnalParams)
int sms_initFrame(int iCurrentFrame, SMS_AnalParams *pAnalParams, int sizeWindow)
{
/* clear deterministic data */
- memset((sfloat *) pAnalParams->ppFrames[iCurrentFrame]->deterministic.pFSinFreq, 0,
+ memset((sfloat *)pAnalParams->ppFrames[iCurrentFrame]->deterministic.pFSinFreq, 0,
sizeof(sfloat) * pAnalParams->nGuides);
- memset((sfloat *) pAnalParams->ppFrames[iCurrentFrame]->deterministic.pFSinAmp, 0,
+ memset((sfloat *)pAnalParams->ppFrames[iCurrentFrame]->deterministic.pFSinAmp, 0,
sizeof(sfloat) * pAnalParams->nGuides);
- memset((sfloat *) pAnalParams->ppFrames[iCurrentFrame]->deterministic.pFSinPha, 0,
+ memset((sfloat *)pAnalParams->ppFrames[iCurrentFrame]->deterministic.pFSinPha, 0,
sizeof(sfloat) * pAnalParams->nGuides);
/* clear peaks */
@@ -697,7 +706,6 @@ int sms_initFrame(int iCurrentFrame, SMS_AnalParams *pAnalParams, int sizeWindow
/* if first frame set center of data around 0 */
if(pAnalParams->ppFrames[iCurrentFrame]->iFrameNum == 1)
pAnalParams->ppFrames[iCurrentFrame]->iFrameSample = 0;
-
/* if not, increment center of data by sizeHop */
else
pAnalParams->ppFrames[iCurrentFrame]->iFrameSample =