sigProcLib: Check for bogus TOA before using it.

This commit is contained in:
Alexander Chemeris 2015-06-04 19:05:28 -04:00
parent ded68da44f
commit 6512812e43
1 changed files with 2 additions and 2 deletions

View File

@ -1285,12 +1285,12 @@ static float computePeakRatio(signalVector *corr,
complex *peak;
float rms, avg = 0.0;
peak = corr->begin() + (int) rint(toa);
/* Check for bogus results */
if ((toa < 0.0) || (toa > corr->size()))
return 0.0;
peak = corr->begin() + (int) rint(toa);
for (int i = 2 * sps; i <= 5 * sps; i++) {
if (peak - i >= corr->begin()) {
avg += (peak - i)->norm2();