From 812258dc01faa6b26534a2aa5d7536b4cb892c01 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Mon, 12 Sep 2016 12:28:31 +0200 Subject: Fixed out of range pointers Fixed bugs: - https://launchpad.net/bugs/1620253 (bzr r15114) --- src/sp-item.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 0ba74f9fd..e03b715c0 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -317,8 +317,11 @@ void SPItem::lowerOne() { auto next_lower = find_last_if(parent->children.begin(), parent->children.iterator_to(*this), &is_item); if (next_lower != parent->children.iterator_to(*this)) { - next_lower--; - Inkscape::XML::Node *ref = next_lower->getRepr(); + Inkscape::XML::Node *ref = nullptr; + if (next_lower != parent->children.begin()) { + next_lower--; + ref = next_lower->getRepr(); + } getRepr()->parent()->changeOrder(getRepr(), ref); } } @@ -326,8 +329,11 @@ void SPItem::lowerOne() { void SPItem::lowerToBottom() { auto bottom = std::find_if(parent->children.begin(), parent->children.iterator_to(*this), &is_item); if (bottom != parent->children.iterator_to(*this)) { - bottom--; - Inkscape::XML::Node *ref = bottom->getRepr() ; + Inkscape::XML::Node *ref = nullptr; + if (bottom != parent->children.begin()) { + bottom--; + ref = bottom->getRepr(); + } parent->getRepr()->changeOrder(getRepr(), ref); } } -- cgit v1.2.3