DynamicBufferIterator: fix end of buffer corner case

This commit is contained in:
Maxime Coste 2011-12-02 18:57:18 +00:00
parent b1daf8de16
commit 8e39edc567

View File

@ -44,7 +44,9 @@ void DynamicBufferIterator::on_modification(const BufferModification& modificati
size_t length = modification.content.length();
if (modification.type == BufferModification::Erase)
{
if (*this <= modification.position + length)
// do not move length on the other side of the inequality,
// as modification.position + length may be after buffer end
if (*this - length <= modification.position)
BufferIterator::operator=(modification.position);
else
*this -= length;