From da63cc999c0fdb2495cbb9471af382fde0e07fea Mon Sep 17 00:00:00 2001 From: jfbastien Date: Tue, 3 Mar 2009 16:29:14 +0000 Subject: [PATCH] Bug 2657248: take two, this time fix it properly! git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@993 7ec92016-0320-0410-acc4-a06ded1c099a --- include/loki/flex/flex_string_shell.h | 33 +++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/include/loki/flex/flex_string_shell.h b/include/loki/flex/flex_string_shell.h index cb6da56..67a42fb 100644 --- a/include/loki/flex/flex_string_shell.h +++ b/include/loki/flex/flex_string_shell.h @@ -807,25 +807,24 @@ private: const typename std::iterator_traits::difference_type n2 = std::distance(s1, s2); + assert(n2 >= 0); - // Empty replacement. - if(0 == n2) - return; - - assert(n2 > 0); - - // Handle aliased replace - static const std::less_equal le = - std::less_equal(); - const bool aliased = le(&*begin(), &*s1) && le(&*s1, &*end()); - if (aliased /* && capacity() < size() - n1 + n2 */) + // Make sure the replacement isn't empty. + if(0 != n2) { - // Aliased replace, copy to new string - flex_string temp; - temp.reserve(size() - n1 + n2); - temp.append(begin(), i1).append(s1, s2).append(i2, end()); - swap(temp); - return; + // Handle aliased replace + static const std::less_equal le = + std::less_equal(); + const bool aliased = le(&*begin(), &*s1) && le(&*s1, &*end()); + if (aliased /* && capacity() < size() - n1 + n2 */) + { + // Aliased replace, copy to new string + flex_string temp; + temp.reserve(size() - n1 + n2); + temp.append(begin(), i1).append(s1, s2).append(i2, end()); + swap(temp); + return; + } } if (n1 > n2)