From 55a048eca6728b0aa813d1cb39f711335d747113 Mon Sep 17 00:00:00 2001 From: cyreve Date: Wed, 13 Feb 2008 23:19:14 +0000 Subject: [PATCH] bug 190722: crash adding newline to simple text object (gcc4.3+) --- src/sp-text.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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()) { -- 2.30.2