[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Wed Oct 19 23:52:23 CEST 2005
SVN commit 472121 by staikos:
add assertions to detect invalid memory access
M +4 -7 kstvector.cpp
--- trunk/extragear/graphics/kst/kst/kstvector.cpp #472120:472121
@@ -106,9 +106,6 @@
#define GENERATE_INTERPOLATION \
- double fj, fdj; \
- int j; \
- \
/** Limits checks - optional? **/ \
if (in_i < 0) { \
return _v[0]; \
@@ -123,10 +120,10 @@
return _v[in_i]; \
} \
\
- fj = in_i * double(_size - 1) / double(ns_i-1); /* scaled index */ \
+ double fj = in_i * double(_size - 1) / double(ns_i-1); /* scaled index */ \
\
- j = int(floor(fj)); /* index of sample one lower */ \
- \
+ int j = int(floor(fj)); /* index of sample one lower */ \
+ assert(j+1 < _size && j >= 0); \
/* This is optimized to avoid unnecessary isnan calls! */ \
if (_v[j + 1] != _v[j + 1]) { \
if (KST_ISNAN(_v[j + 1])) { \
@@ -139,7 +136,7 @@
} \
} \
\
- fdj = fj - float(j); /* fdj is fraction between _v[j] and _v[j+1] */ \
+ double fdj = fj - float(j); /* fdj is fraction between _v[j] and _v[j+1] */ \
\
return _v[j + 1] * fdj + _v[j] * (1.0 - fdj);
More information about the Kst
mailing list