diff options
| author | Eli Zaretskii | 2015-01-19 19:22:17 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-01-19 19:22:17 +0200 |
| commit | fb6462f056f616f3da8ae18037c7c2137fecb6fd (patch) | |
| tree | af4949972ab842afa583e8e81613543726e7cf19 /src | |
| parent | 39585cfd844003df47a554894dfa38573da1203c (diff) | |
| download | emacs-fb6462f056f616f3da8ae18037c7c2137fecb6fd.tar.gz emacs-fb6462f056f616f3da8ae18037c7c2137fecb6fd.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/dispnew.c | 12 | ||||
| -rw-r--r-- | src/xdisp.c | 3 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 04b952cae60..f6a5f3837a3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2015-01-19 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * dispnew.c (adjust_glyph_matrix, realloc_glyph_pool): Verify that | ||
| 4 | Qnil is represented as zero, before using that to initialize parts | ||
| 5 | of the glyph structure. | ||
| 6 | |||
| 7 | * xdisp.c (init_iterator): Verify that Qnil is represented as | ||
| 8 | zero, before using that to initialize parts of the iterator | ||
| 9 | structure. | ||
| 10 | |||
| 1 | 2015-01-19 Paul Eggert <eggert@cs.ucla.edu> | 11 | 2015-01-19 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 12 | ||
| 3 | Prefer memset to repeatedly assigning Qnil | 13 | 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 | |||
| 413 | new_rows = dim.height - matrix->rows_allocated; | 413 | new_rows = dim.height - matrix->rows_allocated; |
| 414 | matrix->rows = xpalloc (matrix->rows, &matrix->rows_allocated, | 414 | matrix->rows = xpalloc (matrix->rows, &matrix->rows_allocated, |
| 415 | new_rows, INT_MAX, sizeof *matrix->rows); | 415 | new_rows, INT_MAX, sizeof *matrix->rows); |
| 416 | /* As a side effect, this sets the object of each glyph in the | ||
| 417 | row to nil, so verify we will indeed get that. Redisplay | ||
| 418 | relies on the object of special glyphs (truncation and | ||
| 419 | continuation glyps and also blanks used to extend each line | ||
| 420 | on a TTY) to be nil. */ | ||
| 421 | verify (NIL_IS_ZERO); | ||
| 416 | memset (matrix->rows + old_alloc, 0, | 422 | memset (matrix->rows + old_alloc, 0, |
| 417 | (matrix->rows_allocated - old_alloc) * sizeof *matrix->rows); | 423 | (matrix->rows_allocated - old_alloc) * sizeof *matrix->rows); |
| 418 | } | 424 | } |
| @@ -1339,6 +1345,12 @@ realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) | |||
| 1339 | ptrdiff_t old_nglyphs = pool->nglyphs; | 1345 | ptrdiff_t old_nglyphs = pool->nglyphs; |
| 1340 | pool->glyphs = xpalloc (pool->glyphs, &pool->nglyphs, | 1346 | pool->glyphs = xpalloc (pool->glyphs, &pool->nglyphs, |
| 1341 | needed - old_nglyphs, -1, sizeof *pool->glyphs); | 1347 | needed - old_nglyphs, -1, sizeof *pool->glyphs); |
| 1348 | /* As a side effect, this sets the object of each glyph to nil, | ||
| 1349 | so verify we will indeed get that. Redisplay relies on the | ||
| 1350 | object of special glyphs (truncation and continuation glyps | ||
| 1351 | and also blanks used to extend each line on a TTY) to be | ||
| 1352 | nil. */ | ||
| 1353 | verify (NIL_IS_ZERO); | ||
| 1342 | memset (pool->glyphs + old_nglyphs, 0, | 1354 | memset (pool->glyphs + old_nglyphs, 0, |
| 1343 | (pool->nglyphs - old_nglyphs) * sizeof *pool->glyphs); | 1355 | (pool->nglyphs - old_nglyphs) * sizeof *pool->glyphs); |
| 1344 | } | 1356 | } |
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, | |||
| 2747 | } | 2747 | } |
| 2748 | 2748 | ||
| 2749 | /* Clear IT. */ | 2749 | /* Clear IT. */ |
| 2750 | /* As a side effect, this sets it->object to nil, so verify we will | ||
| 2751 | indeed get that. */ | ||
| 2752 | verify (NIL_IS_ZERO); | ||
| 2750 | memset (it, 0, sizeof *it); | 2753 | memset (it, 0, sizeof *it); |
| 2751 | it->current.overlay_string_index = -1; | 2754 | it->current.overlay_string_index = -1; |
| 2752 | it->current.dpvec_index = -1; | 2755 | it->current.dpvec_index = -1; |