From: David Kastrup Date: Wed, 9 May 2018 11:48:35 +0000 (+0200) Subject: Issue 5320: beam.cc: avoid calculating an invalid reference X-Git-Url: http://git.savannah.gnu.org/gitweb/?p=lilypond.git;a=commitdiff_plain;h=d63756608d265d7a99444af1123b7be8a06f3cc2 Issue 5320: beam.cc: avoid calculating an invalid reference In calc_beam_segments, an invalid reference to a neighboring segment was calculated (and not used) at the extreme ends of the beam. This caused segfaults on Fedora. Since the reference is used at most twice anyway and in the same expression, it seems easier to just use the expression directly (the invalid cases are then skipped due to short-circuit evaluation). --- diff --git a/lily/beam.cc b/lily/beam.cc index dff6216..9a9ea15 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -457,7 +457,6 @@ Beam::calc_beam_segments (SCM smob) Beam_stem_segment const &seg = segs[j]; for (LEFT_and_RIGHT (event_dir)) { - Beam_stem_segment const &neighbor_seg = segs[j + event_dir]; // TODO: make names clearer? --jneem // on_line_bound: whether the current segment is on the boundary of the WHOLE beam // on_beam_bound: whether the current segment is on the boundary of just that part @@ -471,9 +470,10 @@ Beam::calc_beam_segments (SCM smob) : seg.stem_index_ + 1 < stems.size (); bool event = on_beam_bound - || abs (seg.rank_ - neighbor_seg.rank_) > 1 + || abs (seg.rank_ - segs[j + event_dir].rank_) > 1 || (abs (vertical_count) >= seg.max_connect_ - || abs (vertical_count) >= neighbor_seg.max_connect_); + || abs (vertical_count) + >= segs[j + event_dir].max_connect_); if (!event) // Then this edge of the current segment is irrelevant because it will