From dcb1fef87a4e9ea84e11b815956a0f55e82a99ca Mon Sep 17 00:00:00 2001 From: rousskov <> Date: Thu, 24 Jan 2008 02:24:14 +0000 Subject: [PATCH] String 'call duplication' optimization(?) bypassed calling String::init() when copying a String and called limitInit() directly. That results in an assertion when an empty String is copied. The fix avoids calling limitInit() when an empty String is copied. --- src/String.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/String.cc b/src/String.cc index 9da75947b7..7dc48a694c 100644 --- a/src/String.cc +++ b/src/String.cc @@ -1,6 +1,6 @@ /* - * $Id: String.cc,v 1.27 2008/01/23 03:06:20 amosjeffries Exp $ + * $Id: String.cc,v 1.28 2008/01/23 19:24:14 rousskov Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -119,7 +119,8 @@ String::limitInit(const char *str, int len) String::String (String const &old) : size_(0), len_(0), buf_(NULL) { - limitInit(old.buf(), old.size()); + if (old.size() > 0) + limitInit(old.buf(), old.size()); #if DEBUGSTRINGS StringRegistry::Instance().add(this); -- 2.47.2