[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: avoid calculating an invalid reference (issue 343160043 by

From: dak
Subject: Re: avoid calculating an invalid reference (issue 343160043 by address@hidden)
Date: Wed, 09 May 2018 08:20:32 -0700

Reviewers: mtasaka,

On 2018/05/09 15:07:04, mtasaka wrote:
I checked the patch and it looks good. Also I've confirmed that
applying this
patch actually prevents abort for reported and ( was on RedHat bugzilla).

Thanks, I'll take that as an LGTM then.

Description: 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).

Please review this at

Affected files (+3, -3 lines):
  M lily/

Index: lily/
diff --git a/lily/ b/lily/
index dff62168af0f10a6c8d95dd4048cab42743b8dfa..9a9ea15df2f815c4cc3b8fbdd7ce99cc034e058e 100644
--- a/lily/
+++ b/lily/
@@ -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_)
                            || (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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]