[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Test to determine character left-overhangs a tab stretch.
From: |
Eli Zaretskii |
Subject: |
Re: Test to determine character left-overhangs a tab stretch. |
Date: |
Wed, 14 Nov 2018 17:33:56 +0200 |
> Date: Tue, 13 Nov 2018 12:57:08 -0800
> From: Keith David Bershatsky <address@hidden>
> Cc: address@hidden
>
> Thank you Eli for helping out with this particular issue. I think the
> problem is that first_glyph->type (in the following test) is sometimes
> invalid and that is what causes the crash. The test is designed to skip over
> the area of code when a tab stretch would normally be drawn anew due to the
> next glyph having a left overhang.
>
> Last Commit : Tue Nov 13 22:01:57 2018 +0200
> : Eli Zaretskii <address@hidden>
> : 4a5a17507fe1e12ee02c174350edc479fb01ac01
> : Fix recent change in fileio.c
>
> diff --git a/src/xdisp.c b/src/xdisp.c
> index fa7691c..198a516 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -26841,7 +26841,45 @@ draw_glyphs (struct window *w, int x, struct
> glyph_row *row,
> prepended must be drawn because the first glyph string
> draws over it. */
> i = left_overwritten (head);
> - if (i >= 0)
left_overwritten can return a negative value, in which case this:
> + bool skip_p = false;
> + int beg = i;
> +
> + if (hl == DRAW_CURSOR)
> + while (beg < start)
> + {
> + struct glyph *first_glyph = (row)->glyphs[area] + beg;
> + if (first_glyph != NULL
> + && first_glyph->type != NULL)
attempts to dereference a pointer that is before the beginning of
row->glyphs[area], and you get a segfault. I think your code should
be inside the "if (i >= 0)" clause.
Stepping back, I'm not sure what you do is a good idea. Redrawing
neighboring glyphs due to overhanging is done for a reason, so
skipping it might well produce incorrect display. I advice against
that.