Skip to content

Commit

Permalink
CMSIS-DSP: Ensure correlation array index is signed.
Browse files Browse the repository at this point in the history
This attempts to ensures that even on a 64bit system, the array access
will be treated as a negative number, not a large unsigned offset ending
up reading from the middle of nowhere.
  • Loading branch information
davemgreen committed Mar 7, 2021
1 parent 840f4ff commit b25727e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_correlate_f16.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ void arm_correlate_f16(
if ((((i - j) < srcBLen) && (j < srcALen)))
{
/* z[i] += x[i-j] * y[j] */
sum += pIn1[j] * pIn2[-((int32_t) i - j)];
sum += pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)];
}
}

Expand Down
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_correlate_f32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ void arm_correlate_f32(
if ((((i - j) < srcBLen) && (j < srcALen)))
{
/* z[i] += x[i-j] * y[j] */
sum += pIn1[j] * pIn2[-((int32_t) i - j)];
sum += pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)];
}
}

Expand Down
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_correlate_q15.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ void arm_correlate_q15(
if (((i - j) < srcBLen) && (j < srcALen))
{
/* z[i] += x[i-j] * y[j] */
sum += ((q31_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
sum += ((q31_t) pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_correlate_q31.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ void arm_correlate_q31(
if (((i - j) < srcBLen) && (j < srcALen))
{
/* z[i] += x[i-j] * y[j] */
sum += ((q63_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
sum += ((q63_t) pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_correlate_q7.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ void arm_correlate_q7(
if (((i - j) < srcBLen) && (j < srcALen))
{
/* z[i] += x[i-j] * y[j] */
sum += ((q15_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
sum += ((q15_t) pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)]);
}
}

Expand Down

0 comments on commit b25727e

Please sign in to comment.