while (row < end)
{
- row->glyphs[LEFT_MARGIN_AREA]
- = xnrealloc (row->glyphs[LEFT_MARGIN_AREA],
- dim.width, sizeof (struct glyph));
- /* We actually need to clear only the 'frame' member, but
- it's easier to clear everything. */
- memset (row->glyphs[LEFT_MARGIN_AREA], 0,
- dim.width * sizeof (struct glyph));
+ /* Only realloc if matrix got wider or taller (bug#77961). */
+ if (dim.width > matrix->matrix_w || new_rows)
+ {
+ row->glyphs[LEFT_MARGIN_AREA]
+ = xnrealloc (row->glyphs[LEFT_MARGIN_AREA],
+ dim.width, sizeof (struct glyph));
+ /* We actually need to clear only the 'frame' member, but
+ it's easier to clear everything. */
+ memset (row->glyphs[LEFT_MARGIN_AREA], 0,
+ dim.width * sizeof (struct glyph));
+ }
if ((row == matrix->rows + dim.height - 1
/* The mode line, if displayed, never has marginal