aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-01-19 22:04:33 +0200
committerEli Zaretskii2013-01-19 22:04:33 +0200
commit59ac2d1316937bb013ef437885dcdc0225c71de9 (patch)
treee2272769f60a36aeb74f8f01b479b597455f0065 /src/editfns.c
parent3a955a1f8617ae65709772863a4cb8bb9ec73de7 (diff)
downloademacs-59ac2d1316937bb013ef437885dcdc0225c71de9.tar.gz
emacs-59ac2d1316937bb013ef437885dcdc0225c71de9.zip
Fix crashes with lots of overlays.
src/editfns.c (get_pos_property): Use SAFE_ALLOCA_LISP, to avoid segfault when there are lots of overlays. src/buffer.c (sort_overlays): Use SAFE_NALLOCA, to avoid segfault when there are lots of overlays. See http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00421.html for the details and a way to reproduce.
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 197950517b7..020285cf4ec 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -386,6 +386,7 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
386 ptrdiff_t noverlays; 386 ptrdiff_t noverlays;
387 Lisp_Object *overlay_vec, tem; 387 Lisp_Object *overlay_vec, tem;
388 struct buffer *obuf = current_buffer; 388 struct buffer *obuf = current_buffer;
389 USE_SAFE_ALLOCA;
389 390
390 set_buffer_temp (XBUFFER (object)); 391 set_buffer_temp (XBUFFER (object));
391 392
@@ -398,7 +399,7 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
398 make enough space for all, and try again. */ 399 make enough space for all, and try again. */
399 if (noverlays > 40) 400 if (noverlays > 40)
400 { 401 {
401 overlay_vec = alloca (noverlays * sizeof *overlay_vec); 402 SAFE_ALLOCA_LISP (overlay_vec, noverlays);
402 noverlays = overlays_around (posn, overlay_vec, noverlays); 403 noverlays = overlays_around (posn, overlay_vec, noverlays);
403 } 404 }
404 noverlays = sort_overlays (overlay_vec, noverlays, NULL); 405 noverlays = sort_overlays (overlay_vec, noverlays, NULL);
@@ -421,10 +422,12 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
421 ; /* The overlay will not cover a char inserted at point. */ 422 ; /* The overlay will not cover a char inserted at point. */
422 else 423 else
423 { 424 {
425 SAFE_FREE ();
424 return tem; 426 return tem;
425 } 427 }
426 } 428 }
427 } 429 }
430 SAFE_FREE ();
428 431
429 { /* Now check the text properties. */ 432 { /* Now check the text properties. */
430 int stickiness = text_property_stickiness (prop, position, object); 433 int stickiness = text_property_stickiness (prop, position, object);