[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23869: 25.0.95; replace-match can crash emacs
From: |
Stefan Monnier |
Subject: |
bug#23869: 25.0.95; replace-match can crash emacs |
Date: |
Sun, 03 Jul 2016 16:08:10 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> Morale: a buffer-modification hook should always save-match-data.
Indeed. If it does modify the match data, it's a bug in that hook function.
> + /* The functions below modify the buffer, so they could trigger
> + various modification hooks (see signal_before_change and
> + signal_after_change), which might clobber the match data we need
> + to adjust after the replacement. So we save and restore the
> + match data around the calls. */
> + ptrdiff_t sub_start = search_regs.start[sub];
> + ptrdiff_t sub_end = search_regs.end[sub];
> + save_search_regs ();
I think it's important to avoid a crash, but it's not important to
behave correctly even if the change-hooks modifying the match data.
So if we can find a simpler/cheaper way to avoid the crash, it'd
be preferable.
Stefan