[Kst] extragear/graphics/kst/src/plugins
Adam Treat
treat at kde.org
Tue Nov 28 20:39:17 CET 2006
SVN commit 608879 by treat:
* Invalid read found by valgrind
M +6 -1 fits/common.h
M +6 -1 fits_nonlinear/common.h
--- trunk/extragear/graphics/kst/src/plugins/fits/common.h #608878:608879
@@ -46,7 +46,12 @@
fj = (double)(iIndex * (iLengthActual-1)) / (double)(iLengthDesired-1);
j = (int)floor(fj);
fdj = fj - (double)j;
- value = pArray[j+1] * fdj + pArray[j+0] * (1.0 - fdj);
+
+ //Don't read an invalid index from pArray... found by valgrind
+ double A = j+1 < iLengthActual ? pArray[j+1] : 0;
+ double B = j < iLengthActual ? pArray[j] : 0;
+
+ value = A * fdj + B * (1.0 - fdj);
}
return value;
--- trunk/extragear/graphics/kst/src/plugins/fits_nonlinear/common.h #608878:608879
@@ -36,7 +36,12 @@
fj = (double)(iIndex * (iLengthActual-1)) / (double)(iLengthDesired-1);
j = (int)floor(fj);
fdj = fj - (double)j;
- value = pArray[j+1] * fdj + pArray[j+0] * (1.0 - fdj);
+
+ //Don't read an invalid index from pArray... found by valgrind
+ double A = j+1 < iLengthActual ? pArray[j+1] : 0;
+ double B = j < iLengthActual ? pArray[j] : 0;
+
+ value = A * fdj + B * (1.0 - fdj);
}
return value;
More information about the Kst
mailing list