From: Joe Neeman Date: Mon, 19 Mar 2007 04:59:37 +0000 (+1100) Subject: Ensure that skylines always have at least one building in them. X-Git-Tag: release/2.11.21-1~3^2~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c58452f1046ac805119feb659da9d6244c2f7beb;p=lilypond.git Ensure that skylines always have at least one building in them. Fixes memory corruption bug. --- diff --git a/lily/skyline.cc b/lily/skyline.cc index 9da2606edb..e55ba3a663 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -174,6 +174,12 @@ void Skyline::internal_merge_skyline (list *s1, list *s2, list *const result) { + if (s1->empty () || s2->empty ()) + { + programming_error ("tried to merge an empty skyline"); + return; + } + Real x = -infinity_f; while (!s1->empty ()) { @@ -332,7 +338,7 @@ Skyline::internal_build_skyline (list *boxes, Real horizon_padding, Axis ho Skyline::Skyline () { sky_ = UP; - empty_skyline (&buildings_); + empty_skyline (&buildings_); } Skyline::Skyline (Skyline const &src) @@ -403,6 +409,12 @@ Skyline::insert (Box const &b, Real horizon_padding, Axis a) list other_bld; list my_bld; + /* do the same filtering as in Skyline (vector const&, etc.) */ + Interval iv = b[a]; + iv.widen (horizon_padding); + if (iv.length () <= EPS || b[other_axis (a)].is_empty ()) + return; + my_bld.splice (my_bld.begin (), buildings_); single_skyline (Building (b, horizon_padding, a, sky_), b[a][LEFT], horizon_padding, &other_bld); internal_merge_skyline (&other_bld, &my_bld, &buildings_);