Subject: bug#77233: 31.0.50; crash if message starts with a space and then without it

From: Eli Zaretskii <[email-masked]>
Date: Mon, 24 Mar 2025 21:32:29 +0200

> Date: Mon, 24 Mar 2025 19:13:55 +0000
> From: Pip Cet <[email-masked]>
> Cc: Gerd Möllmann <[email-masked]>, [email-masked], [email-masked]
> 
> Anyway, here's a patch that does this, but it seems too complicated to
> be worth it to me:

A few minor/cosmetic comments about the patch:

> +	  if (!f->current_matrix || f->current_matrix->matrix_h < curY (tty))

How can a frame not have a current_matrix?  That could only mean one
thing: the frame was not completely made, in which case its
after_make_frame flag should be reset.  Such frames should never be
considered by this function, i.e. they should be detected at entry and
the function should then return without doing anything.

> +	  struct glyph_row *row = &f->current_matrix->rows[curY (tty)];
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Please use the MATRIX_ROW macro here.

> +	  int area = 0;
> +	  int x = curX (tty) - 1;
> +	  while (x > row->used[area])
> +	    {
> +	      x -= row->used[area];
> +	      if (area++ == LAST_AREA)
> +		return;
> +	    }
> +	  glyphs[0] = row->glyphs[area][x];
> +	  tty_write_glyphs (f, glyphs, 2);
> +	}

I think this is unnecessarily complicated, since frame glyph matrices
never have marginal areas, they only have the single TEXT_AREA.