diff options
| author | Eli Zaretskii | 2016-10-24 21:37:20 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-10-24 21:37:20 +0300 |
| commit | 96ac0c3ebce825e60595794f99e703ec8302e240 (patch) | |
| tree | 72a6d0c01d7e8541c75ab29f207d4c3758ddc5ca /src | |
| parent | 1047496722a58ef5b736dae64d32adeb58c5055c (diff) | |
| download | emacs-96ac0c3ebce825e60595794f99e703ec8302e240.tar.gz emacs-96ac0c3ebce825e60595794f99e703ec8302e240.zip | |
Yet another fix for using pointers into buffer text
* src/search.c (boyer_moore): Update pointers to buffer text
after call to set_search_regs. (Bug#24358)
Diffstat (limited to 'src')
| -rw-r--r-- | src/search.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/search.c b/src/search.c index f8acd40fa08..b50e7f032d5 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -2014,13 +2014,20 @@ boyer_moore (EMACS_INT n, unsigned char *base_pat, | |||
| 2014 | cursor += dirlen - i - direction; /* fix cursor */ | 2014 | cursor += dirlen - i - direction; /* fix cursor */ |
| 2015 | if (i + direction == 0) | 2015 | if (i + direction == 0) |
| 2016 | { | 2016 | { |
| 2017 | ptrdiff_t position, start, end; | 2017 | ptrdiff_t position, start, end, cursor_off; |
| 2018 | 2018 | ||
| 2019 | cursor -= direction; | 2019 | cursor -= direction; |
| 2020 | 2020 | ||
| 2021 | position = pos_byte + cursor - p2 + ((direction > 0) | 2021 | position = pos_byte + cursor - p2 + ((direction > 0) |
| 2022 | ? 1 - len_byte : 0); | 2022 | ? 1 - len_byte : 0); |
| 2023 | /* set_search_regs might call malloc, which could | ||
| 2024 | cause ralloc.c relocate buffer text. We need to | ||
| 2025 | update pointers into buffer text due to that. */ | ||
| 2026 | cursor_off = cursor - p2; | ||
| 2023 | set_search_regs (position, len_byte); | 2027 | set_search_regs (position, len_byte); |
| 2028 | p_limit = BYTE_POS_ADDR (limit); | ||
| 2029 | p2 = BYTE_POS_ADDR (pos_byte); | ||
| 2030 | cursor = p2 + cursor_off; | ||
| 2024 | 2031 | ||
| 2025 | if (NILP (Vinhibit_changing_match_data)) | 2032 | if (NILP (Vinhibit_changing_match_data)) |
| 2026 | { | 2033 | { |