diff options
| author | Eli Zaretskii | 2016-07-26 18:27:21 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-07-26 18:27:21 +0300 |
| commit | c54238db6aabeb5ebc74ee60af65a8af27aa6426 (patch) | |
| tree | 7c4657886ba0f03c95f4c3d54727c43b089d240e | |
| parent | ac30157b14c07626f76530e47949db053a68875e (diff) | |
| download | emacs-c54238db6aabeb5ebc74ee60af65a8af27aa6426.tar.gz emacs-c54238db6aabeb5ebc74ee60af65a8af27aa6426.zip | |
Avoid segfaults in compute_motion
* src/indent.c (compute_motion): Don't turn on and don't use the
width cache unless the buffer's width-table is non-nil. This
avoids segfaults because code that uses the width cache assumes
the width-table exists. (Bug#24064)
| -rw-r--r-- | src/indent.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/indent.c b/src/indent.c index bc59239f20f..1015259cedd 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1162,7 +1162,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos, | |||
| 1162 | int prev_tab_offset; /* Previous tab offset. */ | 1162 | int prev_tab_offset; /* Previous tab offset. */ |
| 1163 | int continuation_glyph_width; | 1163 | int continuation_glyph_width; |
| 1164 | struct buffer *cache_buffer = current_buffer; | 1164 | struct buffer *cache_buffer = current_buffer; |
| 1165 | struct region_cache *width_cache; | 1165 | struct region_cache *width_cache = NULL; |
| 1166 | 1166 | ||
| 1167 | struct composition_it cmp_it; | 1167 | struct composition_it cmp_it; |
| 1168 | 1168 | ||
| @@ -1170,11 +1170,14 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos, | |||
| 1170 | 1170 | ||
| 1171 | if (cache_buffer->base_buffer) | 1171 | if (cache_buffer->base_buffer) |
| 1172 | cache_buffer = cache_buffer->base_buffer; | 1172 | cache_buffer = cache_buffer->base_buffer; |
| 1173 | width_cache = width_run_cache_on_off (); | ||
| 1174 | if (dp == buffer_display_table ()) | 1173 | if (dp == buffer_display_table ()) |
| 1175 | width_table = (VECTORP (BVAR (current_buffer, width_table)) | 1174 | { |
| 1176 | ? XVECTOR (BVAR (current_buffer, width_table))->contents | 1175 | width_table = (VECTORP (BVAR (current_buffer, width_table)) |
| 1177 | : 0); | 1176 | ? XVECTOR (BVAR (current_buffer, width_table))->contents |
| 1177 | : 0); | ||
| 1178 | if (width_table) | ||
| 1179 | width_cache = width_run_cache_on_off (); | ||
| 1180 | } | ||
| 1178 | else | 1181 | else |
| 1179 | /* If the window has its own display table, we can't use the width | 1182 | /* If the window has its own display table, we can't use the width |
| 1180 | run cache, because that's based on the buffer's display table. */ | 1183 | run cache, because that's based on the buffer's display table. */ |