An iterator is typicall incremented passed the valid data into the 'end'
state. However, if this means that other functions are called with invalid
parameter, we should fix this.
This explains why fontSpan was called with pos==size() while this was not
expected to happen.
This patch reverts partly
f5ad0c128aec (Jean-Marc Lasgouttes; Get rid of
annoying warning message).
FontSpan Paragraph::fontSpan(pos_type pos) const
{
- LBUFERR(pos <= size());
-
- // Last position is a special case. I suspect that it would
- // actually make sense to extend the last font span to cover
- // the last character (JMarc)
- if (pos == size())
- return FontSpan(pos, pos);
+ LBUFERR(pos < size());
pos_type start = 0;
FontList::const_iterator cit = d->fontlist_.begin();
FontIterator & operator++()
{
++pos_;
- if (pos_ > endspan_ || pos_ == bodypos_) {
+ if (pos_ < par_.size() && (pos_ > endspan_ || pos_ == bodypos_)) {
font_ = tm_.displayFont(pit_, pos_);
endspan_ = par_.fontSpan(pos_).last;
}