[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Thu Sep 22 15:01:05 CEST 2005
SVN commit 462951 by staikos:
- add an assert to the planck plugin for safety check
- add lots of asserts to kstrvector, and don't try to resize the vector to 0 and
then read -1 from the data source.
M +1 -0 datasources/planck/planck.cpp
M +12 -2 kstrvector.cpp
--- trunk/extragear/graphics/kst/kst/datasources/planck/planck.cpp #462950:462951
@@ -121,6 +121,7 @@
return 0;
}
+ assert(n != 0);
return _planckObject->readObject(field, v, start + s, start + s + n - 1);
}
--- trunk/extragear/graphics/kst/kst/kstrvector.cpp #462950:462951
@@ -459,7 +459,9 @@
new_nf = fc - new_f0;
}
if (new_nf <= 0) {
- new_nf = new_f0 = 0;
+ // Tried to read starting past the end.
+ new_f0 = 0;
+ new_nf = 1;
}
}
@@ -489,6 +491,7 @@
_numSamples = (NF-1)*SPF+1;
}
+ // FIXME: use memmove()
for (i = 0; i < _numSamples; i++) {
_v[i] = _v[i+shift];
}
@@ -563,6 +566,7 @@
bool rc = resize((new_nf - 1)*SPF + 1);
if (!rc) {
// FIXME: handle failed resize
+ abort();
}
}
@@ -572,9 +576,15 @@
// read the new data from file
if (_file->samplesPerFrame(_field) > 1) {
+ assert(new_nf - NF - 1 > 0 || new_nf - NF - 1 == -1);
+ assert(new_f0 + NF >= 0);
+ assert(new_f0 + new_nf - 1 >= 0);
n_read = _file->readField(_v+NF*SPF, _field, new_f0 + NF, new_nf - NF - 1);
- n_read += _file->readField(_v+(new_nf-1)*SPF, _field, new_f0 + new_nf-1, -1);
+ n_read += _file->readField(_v+(new_nf-1)*SPF, _field, new_f0 + new_nf - 1, -1);
} else {
+ //kdDebug() << "Reading into _v=" << (void*)_v << " which has size " << _size << " and starting at offset " << NF*SPF << " for s=" << new_f0 + NF << " and n=" << new_nf - NF << endl;
+ assert(new_f0 + NF >= 0);
+ assert(new_nf - NF > 0 || new_nf - NF == -1);
n_read = _file->readField(_v+NF*SPF, _field, new_f0 + NF, new_nf - NF);
}
}
More information about the Kst
mailing list