From 7f264f779b4da969bf5765d7ab91323a4747c7f3 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 3 Sep 2016 17:30:18 +0000 Subject: [PATCH] Check segment index values in compress_segments --- similar/editor/segment.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/similar/editor/segment.cpp b/similar/editor/segment.cpp index 41bc987f0..cd1c15f3f 100644 --- a/similar/editor/segment.cpp +++ b/similar/editor/segment.cpp @@ -660,14 +660,12 @@ static void compress_segments(void) if (l == seg) l = hole; - auto sp = &Segments[hole]; - range_for (auto &s, sp->children) + auto &sp = *vsegptr(hole); + range_for (auto &s, sp.children) { if (IS_CHILD(s)) { - auto csegp = &Segments[s]; - // Find out on what side the segment connection to the former seg is on in *csegp. - range_for (auto &t, csegp->children) + range_for (auto &t, vsegptr(s)->children) { if (t == seg) { t = hole; // It used to be connected to seg, so make it connected to hole @@ -677,7 +675,7 @@ static void compress_segments(void) } // end for s //Update object segment pointers - range_for (const auto objp, objects_in(*sp)) + range_for (const auto objp, objects_in(sp)) { Assert(objp->segnum == seg); objp->segnum = hole;