Fix wrong array bounds
This commit is contained in:
1 parent
cbbed7b4a2
commit
64b4f15281
1 file changed
+2
-2
@@ -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){
|
||||
|
||||
Reference in new issue
Block a user