From: Eli Zaretskii Date: Mon, 24 Oct 2016 18:37:20 +0000 (+0300) Subject: Yet another fix for using pointers into buffer text X-Git-Tag: emacs-25.1.90~81 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=96ac0c3ebce825e60595794f99e703ec8302e240;p=emacs.git 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) --- 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, cursor += dirlen - i - direction; /* fix cursor */ if (i + direction == 0) { - ptrdiff_t position, start, end; + ptrdiff_t position, start, end, cursor_off; cursor -= direction; position = pos_byte + cursor - p2 + ((direction > 0) ? 1 - len_byte : 0); + /* set_search_regs might call malloc, which could + cause ralloc.c relocate buffer text. We need to + update pointers into buffer text due to that. */ + cursor_off = cursor - p2; set_search_regs (position, len_byte); + p_limit = BYTE_POS_ADDR (limit); + p2 = BYTE_POS_ADDR (pos_byte); + cursor = p2 + cursor_off; if (NILP (Vinhibit_changing_match_data)) {