summaryrefslogtreecommitdiff
path: root/sms/sms.c
diff options
context:
space:
mode:
authorJohn Glover <glover.john@gmail.com>2010-12-02 19:39:43 +0000
committerJohn Glover <glover.john@gmail.com>2010-12-02 19:39:43 +0000
commit6d21f1d6741851711e3bc589a44e194634c19eca (patch)
treebc32aad26495b9c9ce1a84664651c5cbd248bbda /sms/sms.c
parente5625a21b62f11c7eccc0808a77766b50d973ea4 (diff)
downloadsimpl-6d21f1d6741851711e3bc589a44e194634c19eca.tar.gz
simpl-6d21f1d6741851711e3bc589a44e194634c19eca.tar.bz2
simpl-6d21f1d6741851711e3bc589a44e194634c19eca.zip
Fixed some memory bugs in SMS caused by incorrect array boundary checking
Diffstat (limited to 'sms/sms.c')
-rw-r--r--sms/sms.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sms/sms.c b/sms/sms.c
index 78ccb6b..3a02b4b 100644
--- a/sms/sms.c
+++ b/sms/sms.c
@@ -344,14 +344,21 @@ int sms_initAnalysis(SMS_AnalParams *pAnalParams)
sms_error("Could not allocate memory for guides");
return -1;
}
+
/* initial guide values */
- if(pAnalParams->iFormat == SMS_FORMAT_H ||
- pAnalParams->iFormat == SMS_FORMAT_HP)
+ for (i = 0; i < pAnalParams->nGuides; i++)
{
- for (i = 0; i < pAnalParams->nGuides; i++)
+ if(pAnalParams->iFormat == SMS_FORMAT_H || pAnalParams->iFormat == SMS_FORMAT_HP)
{
pAnalParams->guides[i].fFreq = pAnalParams->fDefaultFundamental * (i + 1);
}
+ else
+ {
+ pAnalParams->guides[i].fFreq = 0.0;
+ }
+ pAnalParams->guides[i].fMag = 0.0;
+ pAnalParams->guides[i].iPeakChosen = -1;
+ pAnalParams->guides[i].iStatus = 0;
}
/* stochastic analysis */
@@ -671,7 +678,7 @@ int sms_initFrame(int iCurrentFrame, SMS_AnalParams *pAnalParams, int sizeWindow
pAnalParams->ppFrames[iCurrentFrame-1]->iFrameSample + pAnalParams->sizeHop;
/* check for end of sound */
- if ((pAnalParams->ppFrames[iCurrentFrame]->iFrameSample + (sizeWindow+1)/2) >= pAnalParams->iSizeSound
+ if((pAnalParams->ppFrames[iCurrentFrame]->iFrameSample + (sizeWindow+1)/2) >= pAnalParams->iSizeSound
&& pAnalParams->iSizeSound > 0)
{
pAnalParams->ppFrames[iCurrentFrame]->iFrameNum = -1;