emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c54238d: Avoid segfaults in compute_motion


From: Eli Zaretskii
Subject: [Emacs-diffs] master c54238d: Avoid segfaults in compute_motion
Date: Tue, 26 Jul 2016 15:28:05 +0000 (UTC)

branch: master
commit c54238db6aabeb5ebc74ee60af65a8af27aa6426
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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)
---
 src/indent.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/indent.c b/src/indent.c
index bc59239..1015259 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -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.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]