From: Reinhold Kainhofer Date: Tue, 23 Aug 2011 20:34:46 +0000 (+0200) Subject: Fix memleak: temporary skyline objects for systems were never deleted X-Git-Tag: release/2.15.10-1~19 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=13da351ae100d476532c18241bbe91862fd287ed;p=lilypond.git Fix memleak: temporary skyline objects for systems were never deleted --- diff --git a/lily/skyline.cc b/lily/skyline.cc index b6ea6b791b..8f62710b09 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -514,6 +514,7 @@ Skyline::distance (Skyline const &other, Real horizon_padding) const Skyline const *padded_this = this; Skyline const *padded_other = &other; + bool created_tmp_skylines = false; /* For systems, padding is not added at creation time. Padding is @@ -525,6 +526,7 @@ Skyline::distance (Skyline const &other, Real horizon_padding) const { padded_this = new Skyline (*padded_this, horizon_padding, X_AXIS); padded_other = new Skyline (*padded_other, horizon_padding, X_AXIS); + created_tmp_skylines = true; } list::const_iterator i = padded_this->buildings_.begin (); @@ -544,6 +546,13 @@ Skyline::distance (Skyline const &other, Real horizon_padding) const j++; start = end; } + + if (created_tmp_skylines) + { + delete padded_this; + delete padded_other; + } + return dist; }