Fix wrong array bounds

This commit is contained in:
Flamefire committed 2014-03-24 02:00:41 +01:00
1 parent cbbed7b4a2
commit 64b4f15281
1 file changed
+2 -2
+2 -2
View File
@@ -43,7 +43,7 @@ void Init(double baseToneFrequency, int minHalfTone, int maxHalfTone){
DeInit();
if(maxHalfTone <= 0)
return;
SamplesPerPeriodPerTone = (double*) malloc(MaxHalfTone * sizeof(double));
SamplesPerPeriodPerTone = (double*) malloc((MaxHalfTone + 1) * sizeof(double));
//Init Array to avoid costly calculations
for (int toneIndex = 0; toneIndex <= MaxHalfTone; toneIndex++)
{
@@ -105,7 +105,7 @@ int GetTone(double *samples, int sampleCt, float *weights){
if (curWeight < minWeight)
minWeight = curWeight;
weights[toneIndex] = (float) curWeight;
weights[toneIndex - MinHalfTone] = (float) curWeight;
}
if(maxWeight - minWeight > 0.01){