From 637495a778db254d15643e2cd13d8cf3b2915eae Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 13 Feb 2008 23:19:14 +0000 Subject: bug 190722: crash adding newline to simple text object (gcc4.3+) (bzr r4728) --- src/sp-text.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 5d1abbb3a..810df2530 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -748,11 +748,14 @@ void TextTagAttributes::mergeInto(Inkscape::Text::Layout::OptionalTextTagAttrs * void TextTagAttributes::mergeSingleAttribute(std::vector *output_list, std::vector const &parent_list, unsigned parent_offset, std::vector const *overlay_list) { + output_list->clear(); if (overlay_list == NULL) { - output_list->resize(std::max(0, (int)parent_list.size() - (int)parent_offset)); - std::copy(parent_list.begin() + parent_offset, parent_list.end(), output_list->begin()); + if (parent_list.size() > parent_offset) + { + output_list->reserve(parent_list.size() - parent_offset); + std::copy(parent_list.begin() + parent_offset, parent_list.end(), std::back_inserter(*output_list)); + } } else { - output_list->clear(); output_list->reserve(std::max((int)parent_list.size() - (int)parent_offset, (int)overlay_list->size())); unsigned overlay_offset = 0; while (parent_offset < parent_list.size() || overlay_offset < overlay_list->size()) { -- cgit v1.2.3