ref: d8c21a32aec0fd7e13fb8e45ee5f630dc7bce1dd
parent: abb0ddb38d0671cdc4b2795a579b8d46b39bd130
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Aug 18 22:28:37 EDT 2023
fix underflowing index in beat tracking logic
--- a/src/tempo/beattracking.c
+++ b/src/tempo/beattracking.c
@@ -269,14 +269,14 @@
if (gp < 2) return 4;
if (acflen > 6 * gp + 2) {
for (k = -2; k < 2; k++) {
- three_energy += acf->data[3 * gp + k];
- four_energy += acf->data[4 * gp + k];
+ three_energy += acf->data[3 * (int)gp + k];
+ four_energy += acf->data[4 * (int)gp + k];
}
} else {
/*Expanded to be more accurate in time sig estimation */
for (k = -2; k < 2; k++) {
- three_energy += acf->data[3 * gp + k] + acf->data[6 * gp + k];
- four_energy += acf->data[4 * gp + k] + acf->data[2 * gp + k];
+ three_energy += acf->data[3 * (int)gp + k] + acf->data[6 * (int)gp + k];
+ four_energy += acf->data[4 * (int)gp + k] + acf->data[2 * (int)gp + k];
}
}
return (three_energy > four_energy) ? 3 : 4;