Commit c54238db authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

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)
parent ac30157b
......@@ -1162,7 +1162,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
int prev_tab_offset; /* Previous tab offset. */
int continuation_glyph_width;
struct buffer *cache_buffer = current_buffer;
struct region_cache *width_cache;
struct region_cache *width_cache = NULL;
struct composition_it cmp_it;
......@@ -1170,11 +1170,14 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
if (cache_buffer->base_buffer)
cache_buffer = cache_buffer->base_buffer;
width_cache = width_run_cache_on_off ();
if (dp == buffer_display_table ())
width_table = (VECTORP (BVAR (current_buffer, width_table))
? XVECTOR (BVAR (current_buffer, width_table))->contents
: 0);
{
width_table = (VECTORP (BVAR (current_buffer, width_table))
? XVECTOR (BVAR (current_buffer, width_table))->contents
: 0);
if (width_table)
width_cache = width_run_cache_on_off ();
}
else
/* If the window has its own display table, we can't use the width
run cache, because that's based on the buffer's display table. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment