Remove unreliable test for match data clobbering
* src/search.c (Freplace_match): Don't test for change in search_regs start and end, this is unreliable if change hooks modify text earlier in the buffer (bug#35264).
This commit is contained in:
parent
01bd4d1a82
commit
487498e497
1 changed files with 5 additions and 6 deletions
11
src/search.c
11
src/search.c
|
@ -2723,7 +2723,6 @@ since only regular expressions have distinguished subexpressions. */)
|
|||
}
|
||||
|
||||
newpoint = sub_start + SCHARS (newtext);
|
||||
ptrdiff_t newstart = sub_start == sub_end ? newpoint : sub_start;
|
||||
|
||||
/* Replace the old text with the new in the cleanest possible way. */
|
||||
replace_range (sub_start, sub_end, newtext, 1, 0, 1, true);
|
||||
|
@ -2739,11 +2738,11 @@ since only regular expressions have distinguished subexpressions. */)
|
|||
/* The replace_range etc. functions can trigger modification hooks
|
||||
(see signal_before_change and signal_after_change). Try to error
|
||||
out if these hooks clobber the match data since clobbering can
|
||||
result in confusing bugs. Although this sanity check does not
|
||||
catch all possible clobberings, it should catch many of them. */
|
||||
if (! (search_regs.num_regs == num_regs
|
||||
&& search_regs.start[sub] == newstart
|
||||
&& search_regs.end[sub] == newpoint))
|
||||
result in confusing bugs. We used to check for changes in
|
||||
search_regs start and end, but that fails if modification hooks
|
||||
remove or add text earlier in the buffer, so just check num_regs
|
||||
now. */
|
||||
if (search_regs.num_regs != num_regs)
|
||||
error ("Match data clobbered by buffer modification hooks");
|
||||
|
||||
/* Put point back where it was in the text, if possible. */
|
||||
|
|
Loading…
Add table
Reference in a new issue