From: dvlierop2 Date: Thu, 21 May 2009 19:52:03 +0000 (+0000) Subject: Fix crash reported in bug 214186 (related to the "remove overlap" function in the... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=08db608c9e85ffeb134043395b2b0f8cefec43c9;p=inkscape.git Fix crash reported in bug 214186 (related to the "remove overlap" function in the align dialog) --- diff --git a/src/removeoverlap/removeoverlap.cpp b/src/removeoverlap/removeoverlap.cpp index 084f95dfe..975b4becb 100644 --- a/src/removeoverlap/removeoverlap.cpp +++ b/src/removeoverlap/removeoverlap.cpp @@ -52,6 +52,17 @@ void removeoverlap(GSList const *const items, double const xGap, double const yG if (item_box) { Geom::Point min(item_box->min() - .5*gap); Geom::Point max(item_box->max() + .5*gap); + // A negative gap is allowed, but will lead to problems when the gap is larger than + // the bounding box (in either X or Y direction, or both); min will have become max + // now, which cannot be handled by Rectangle() which is called below. And how will + // removeRectangleOverlap handle such a case? + // That's why we will enforce some boundaries on min and max here: + if (max[X] < min[X]) { + min[X] = max[X] = (min[X] + max[X])/2; + } + if (max[Y] < min[Y]) { + min[Y] = max[Y] = (min[Y] + max[Y])/2; + } Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]); records.push_back(Record(*it, item_box->midpoint(), vspc_rect)); rs.push_back(vspc_rect);