Blob Blame History Raw
Avoid copying a vector when start offset is beyond the end.
This fixes a segfault when compiled with gcc-4.3 (#432220)

Lubomir Kundrak <lkundrak@redhat.com>

diff -urp inkscape-0.45.1+0.46pre1.orig/src/sp-text.cpp inkscape-0.45.1+0.46pre1/src/sp-text.cpp
--- inkscape-0.45.1+0.46pre1.orig/src/sp-text.cpp	2008-01-15 00:24:22.000000000 +0100
+++ inkscape-0.45.1+0.46pre1/src/sp-text.cpp	2008-02-13 20:44:34.000000000 +0100
@@ -749,8 +749,10 @@ void TextTagAttributes::mergeInto(Inksca
 void TextTagAttributes::mergeSingleAttribute(std::vector<SVGLength> *output_list, std::vector<SVGLength> const &parent_list, unsigned parent_offset, std::vector<SVGLength> const *overlay_list)
 {
     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_offset < parent_list.size()) {
+            output_list->resize((int)parent_list.size() - (int)parent_offset);
+            std::copy(parent_list.begin() + parent_offset, parent_list.end(), output_list->begin());
+        }
     } else {
         output_list->clear();
         output_list->reserve(std::max((int)parent_list.size() - (int)parent_offset, (int)overlay_list->size()));