diff options
| author | Noam Postavsky | 2018-03-30 16:44:24 -0400 |
|---|---|---|
| committer | Paul Eggert | 2018-03-30 14:26:25 -0700 |
| commit | 96b8747d5c5d747af13fd84d8fe0308ef2a0ea7a (patch) | |
| tree | 1b7cd8463b098f6386b0b8be81f1ab755b6308b9 /src | |
| parent | 842b3d7412eaed6b2c9f90c3361abb4932ec0b1d (diff) | |
| download | emacs-96b8747d5c5d747af13fd84d8fe0308ef2a0ea7a.tar.gz emacs-96b8747d5c5d747af13fd84d8fe0308ef2a0ea7a.zip | |
Fix another case of freed markers in the undo-list (Bug#30931)
* src/alloc.c (free_marker): Remove.
* src/editfns.c (save_restriction_restore):
* src/insdel.c (signal_before_change): Detach the markers from the
buffer when we're done with them instead of calling free_marker on
them.
* test/src/editfns-tests.el (delete-region-undo-markers-1)
(delete-region-undo-markers-2): New tests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 9 | ||||
| -rw-r--r-- | src/editfns.c | 10 | ||||
| -rw-r--r-- | src/insdel.c | 7 | ||||
| -rw-r--r-- | src/lisp.h | 1 |
4 files changed, 11 insertions, 16 deletions
diff --git a/src/alloc.c b/src/alloc.c index 369592d70ee..9fdcc7306a8 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3878,15 +3878,6 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos) | |||
| 3878 | return obj; | 3878 | return obj; |
| 3879 | } | 3879 | } |
| 3880 | 3880 | ||
| 3881 | /* Put MARKER back on the free list after using it temporarily. */ | ||
| 3882 | |||
| 3883 | void | ||
| 3884 | free_marker (Lisp_Object marker) | ||
| 3885 | { | ||
| 3886 | unchain_marker (XMARKER (marker)); | ||
| 3887 | free_misc (marker); | ||
| 3888 | } | ||
| 3889 | |||
| 3890 | 3881 | ||
| 3891 | /* Return a newly created vector or string with specified arguments as | 3882 | /* Return a newly created vector or string with specified arguments as |
| 3892 | elements. If all the arguments are characters that can fit | 3883 | elements. If all the arguments are characters that can fit |
diff --git a/src/editfns.c b/src/editfns.c index 727f2d0080c..84de6792738 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3899,10 +3899,12 @@ save_restriction_restore (Lisp_Object data) | |||
| 3899 | 3899 | ||
| 3900 | buf->clip_changed = 1; /* Remember that the narrowing changed. */ | 3900 | buf->clip_changed = 1; /* Remember that the narrowing changed. */ |
| 3901 | } | 3901 | } |
| 3902 | /* This isn’t needed anymore, so don’t wait for GC. | 3902 | /* This isn’t needed anymore, so don’t wait for GC. Do not call |
| 3903 | Do not call free_marker on XCAR (data) or XCDR (data), | 3903 | free_marker on XCAR (data) or XCDR (data), though, since |
| 3904 | though, since record_marker_adjustments may have put | 3904 | record_marker_adjustments may have put them on the buffer’s |
| 3905 | them on the buffer’s undo list (Bug#30931). */ | 3905 | undo list (Bug#30931). Just detach them instead. */ |
| 3906 | Fset_marker (XCAR (data), Qnil, Qnil); | ||
| 3907 | Fset_marker (XCDR (data), Qnil, Qnil); | ||
| 3906 | free_cons (XCONS (data)); | 3908 | free_cons (XCONS (data)); |
| 3907 | } | 3909 | } |
| 3908 | else | 3910 | else |
diff --git a/src/insdel.c b/src/insdel.c index 02e3f41bc9f..697395c507b 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -2148,10 +2148,13 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int, | |||
| 2148 | FETCH_START, FETCH_END, Qnil); | 2148 | FETCH_START, FETCH_END, Qnil); |
| 2149 | } | 2149 | } |
| 2150 | 2150 | ||
| 2151 | /* Detach the markers now that we're done with them. Don't directly | ||
| 2152 | free them, since the change functions could have caused them to | ||
| 2153 | be inserted into the undo list (Bug#30931). */ | ||
| 2151 | if (! NILP (start_marker)) | 2154 | if (! NILP (start_marker)) |
| 2152 | free_marker (start_marker); | 2155 | Fset_marker (start_marker, Qnil, Qnil); |
| 2153 | if (! NILP (end_marker)) | 2156 | if (! NILP (end_marker)) |
| 2154 | free_marker (end_marker); | 2157 | Fset_marker (end_marker, Qnil, Qnil); |
| 2155 | RESTORE_VALUE; | 2158 | RESTORE_VALUE; |
| 2156 | 2159 | ||
| 2157 | unbind_to (count, Qnil); | 2160 | unbind_to (count, Qnil); |
diff --git a/src/lisp.h b/src/lisp.h index b931d23bf38..f471b216587 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3812,7 +3812,6 @@ extern Lisp_Object make_save_funcptr_ptr_obj (void (*) (void), void *, | |||
| 3812 | extern Lisp_Object make_save_memory (Lisp_Object *, ptrdiff_t); | 3812 | extern Lisp_Object make_save_memory (Lisp_Object *, ptrdiff_t); |
| 3813 | extern void free_save_value (Lisp_Object); | 3813 | extern void free_save_value (Lisp_Object); |
| 3814 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); | 3814 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); |
| 3815 | extern void free_marker (Lisp_Object); | ||
| 3816 | extern void free_cons (struct Lisp_Cons *); | 3815 | extern void free_cons (struct Lisp_Cons *); |
| 3817 | extern void init_alloc_once (void); | 3816 | extern void init_alloc_once (void); |
| 3818 | extern void init_alloc (void); | 3817 | extern void init_alloc (void); |