From fb6462f056f616f3da8ae18037c7c2137fecb6fd Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 19 Jan 2015 19:22:17 +0200 Subject: [PATCH] Verify that Qnil is zero before relying on that in redisplay. src/dispnew.c (adjust_glyph_matrix, realloc_glyph_pool): Verify that Qnil is represented as zero, before using that to initialize parts of the glyph structure. src/xdisp.c (init_iterator): Verify that Qnil is represented as zero, before using that to initialize parts of the iterator structure. --- src/ChangeLog | 10 ++++++++++ src/dispnew.c | 12 ++++++++++++ src/xdisp.c | 3 +++ 3 files changed, 25 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 04b952cae60..f6a5f3837a3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2015-01-19 Eli Zaretskii + + * dispnew.c (adjust_glyph_matrix, realloc_glyph_pool): Verify that + Qnil is represented as zero, before using that to initialize parts + of the glyph structure. + + * xdisp.c (init_iterator): Verify that Qnil is represented as + zero, before using that to initialize parts of the iterator + structure. + 2015-01-19 Paul Eggert Prefer memset to repeatedly assigning Qnil diff --git a/src/dispnew.c b/src/dispnew.c index a643d58e492..4aaf6db3a86 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -413,6 +413,12 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y new_rows = dim.height - matrix->rows_allocated; matrix->rows = xpalloc (matrix->rows, &matrix->rows_allocated, new_rows, INT_MAX, sizeof *matrix->rows); + /* As a side effect, this sets the object of each glyph in the + row to nil, so verify we will indeed get that. Redisplay + relies on the object of special glyphs (truncation and + continuation glyps and also blanks used to extend each line + on a TTY) to be nil. */ + verify (NIL_IS_ZERO); memset (matrix->rows + old_alloc, 0, (matrix->rows_allocated - old_alloc) * sizeof *matrix->rows); } @@ -1339,6 +1345,12 @@ realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) ptrdiff_t old_nglyphs = pool->nglyphs; pool->glyphs = xpalloc (pool->glyphs, &pool->nglyphs, needed - old_nglyphs, -1, sizeof *pool->glyphs); + /* As a side effect, this sets the object of each glyph to nil, + so verify we will indeed get that. Redisplay relies on the + object of special glyphs (truncation and continuation glyps + and also blanks used to extend each line on a TTY) to be + nil. */ + verify (NIL_IS_ZERO); memset (pool->glyphs + old_nglyphs, 0, (pool->nglyphs - old_nglyphs) * sizeof *pool->glyphs); } diff --git a/src/xdisp.c b/src/xdisp.c index f006f8e0b94..2442367d3b5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -2747,6 +2747,9 @@ init_iterator (struct it *it, struct window *w, } /* Clear IT. */ + /* As a side effect, this sets it->object to nil, so verify we will + indeed get that. */ + verify (NIL_IS_ZERO); memset (it, 0, sizeof *it); it->current.overlay_string_index = -1; it->current.dpvec_index = -1; -- 2.39.5