diff options
| author | Glenn Morris | 2020-04-18 07:50:22 -0700 |
|---|---|---|
| committer | Glenn Morris | 2020-04-18 07:50:22 -0700 |
| commit | 4819bea6900348f923e0de58995ec41760993b6c (patch) | |
| tree | df5ba765ab0270a215671959a099a65e9f2a2f58 /src | |
| parent | 9dac60b1bf449cc42fe77bc4f3a85bad55afa00f (diff) | |
| parent | f3b62b6c62c41d2e5d15418ea940bce6b11bdf7d (diff) | |
| download | emacs-4819bea6900348f923e0de58995ec41760993b6c.tar.gz emacs-4819bea6900348f923e0de58995ec41760993b6c.zip | |
Merge from origin/emacs-27
f3b62b6c62 (origin/emacs-27) Avoid crashes in regex-emacs.c due to GC
175c61c18b Fix "C-u M-!" when 'shell-command-dont-erase-buffer' is no...
6b297519b5 Fix cl-most-positive-float doc typo
c36c5a3ded ; lisp/ldefs-boot.el: Update.
3876a60569 Fix a typo in calculator.el
9e832ba91b * lisp/erc/erc.el: Add URL to the new ERC page on the Emac...
# Conflicts:
# etc/NEWS
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex-emacs.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 9fd23943402..9cade11c9fb 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c | |||
| @@ -3848,6 +3848,12 @@ re_match_2 (struct re_pattern_buffer *bufp, | |||
| 3848 | return result; | 3848 | return result; |
| 3849 | } | 3849 | } |
| 3850 | 3850 | ||
| 3851 | static void | ||
| 3852 | unwind_re_match (void *ptr) | ||
| 3853 | { | ||
| 3854 | struct buffer *b = (struct buffer *) ptr; | ||
| 3855 | b->text->inhibit_shrinking = 0; | ||
| 3856 | } | ||
| 3851 | 3857 | ||
| 3852 | /* This is a separate function so that we can force an alloca cleanup | 3858 | /* This is a separate function so that we can force an alloca cleanup |
| 3853 | afterwards. */ | 3859 | afterwards. */ |
| @@ -3944,6 +3950,19 @@ re_match_2_internal (struct re_pattern_buffer *bufp, | |||
| 3944 | 3950 | ||
| 3945 | INIT_FAIL_STACK (); | 3951 | INIT_FAIL_STACK (); |
| 3946 | 3952 | ||
| 3953 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 3954 | |||
| 3955 | /* Prevent shrinking and relocation of buffer text if GC happens | ||
| 3956 | while we are inside this function. The calls to | ||
| 3957 | UPDATE_SYNTAX_TABLE_* macros can trigger GC if they call Lisp, | ||
| 3958 | and we have C pointers to buffer text that must not become | ||
| 3959 | invalid as result of GC. */ | ||
| 3960 | if (!current_buffer->text->inhibit_shrinking) | ||
| 3961 | { | ||
| 3962 | record_unwind_protect_ptr (unwind_re_match, current_buffer); | ||
| 3963 | current_buffer->text->inhibit_shrinking = 1; | ||
| 3964 | } | ||
| 3965 | |||
| 3947 | /* Do not bother to initialize all the register variables if there are | 3966 | /* Do not bother to initialize all the register variables if there are |
| 3948 | no groups in the pattern, as it takes a fair amount of time. If | 3967 | no groups in the pattern, as it takes a fair amount of time. If |
| 3949 | there are groups, we include space for register 0 (the whole | 3968 | there are groups, we include space for register 0 (the whole |
| @@ -3960,6 +3979,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, | |||
| 3960 | /* The starting position is bogus. */ | 3979 | /* The starting position is bogus. */ |
| 3961 | if (pos < 0 || pos > size1 + size2) | 3980 | if (pos < 0 || pos > size1 + size2) |
| 3962 | { | 3981 | { |
| 3982 | unbind_to (count, Qnil); | ||
| 3963 | SAFE_FREE (); | 3983 | SAFE_FREE (); |
| 3964 | return -1; | 3984 | return -1; |
| 3965 | } | 3985 | } |
| @@ -4174,6 +4194,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, | |||
| 4174 | 4194 | ||
| 4175 | DEBUG_PRINT ("Returning %td from re_match_2.\n", dcnt); | 4195 | DEBUG_PRINT ("Returning %td from re_match_2.\n", dcnt); |
| 4176 | 4196 | ||
| 4197 | unbind_to (count, Qnil); | ||
| 4177 | SAFE_FREE (); | 4198 | SAFE_FREE (); |
| 4178 | return dcnt; | 4199 | return dcnt; |
| 4179 | } | 4200 | } |
| @@ -5020,6 +5041,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, | |||
| 5020 | if (best_regs_set) | 5041 | if (best_regs_set) |
| 5021 | goto restore_best_regs; | 5042 | goto restore_best_regs; |
| 5022 | 5043 | ||
| 5044 | unbind_to (count, Qnil); | ||
| 5023 | SAFE_FREE (); | 5045 | SAFE_FREE (); |
| 5024 | 5046 | ||
| 5025 | return -1; /* Failure to match. */ | 5047 | return -1; /* Failure to match. */ |