From 8e39edc5675509d7f65b6b44c4f9f46c649d9929 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 2 Dec 2011 18:57:18 +0000 Subject: DynamicBufferIterator: fix end of buffer corner case --- src/dynamic_buffer_iterator.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/dynamic_buffer_iterator.cc') diff --git a/src/dynamic_buffer_iterator.cc b/src/dynamic_buffer_iterator.cc index fac3cd39..e434ded6 100644 --- a/src/dynamic_buffer_iterator.cc +++ b/src/dynamic_buffer_iterator.cc @@ -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; -- cgit v1.2.3