diff options
author | Glenn Morris <rgm@gnu.org> | 2012-05-26 18:06:44 -0700 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2012-05-26 18:06:44 -0700 |
commit | 33017fafd17d722e82a268e9b272f27df261e09d (patch) | |
tree | 9c34640f09d51059804961d697ed9b07e19571d3 /src/search.c | |
parent | caf8a9b2b301aba06735d403317b75b41df59bfe (diff) | |
parent | ed7bebbb489cf6f893fc35a2a6714b0d8e7e8a90 (diff) | |
download | emacs-33017fafd17d722e82a268e9b272f27df261e09d.tar.gz |
Merge from emacs-24; up to 2012-04-24T08:35:02Z!lekktu@gmail.com
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/search.c b/src/search.c index a9542a2ed97..5608e344e75 100644 --- a/src/search.c +++ b/src/search.c @@ -1159,12 +1159,25 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, while (n < 0) { ptrdiff_t val; + +#ifdef REL_ALLOC + /* re_search_2 below is passed C pointers to buffer text. + If some code called by it causes memory (re)allocation, + buffer text could be relocated on platforms that use + REL_ALLOC, which invalidates those C pointers. So we + inhibit relocation of buffer text for as long as + re_search_2 runs. */ + r_alloc_inhibit_buffer_relocation (1); +#endif val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, pos_byte - BEGV_BYTE, lim_byte - pos_byte, (NILP (Vinhibit_changing_match_data) ? &search_regs : &search_regs_1), /* Don't allow match past current point */ pos_byte - BEGV_BYTE); +#ifdef REL_ALLOC + r_alloc_inhibit_buffer_relocation (0); +#endif if (val == -2) { matcher_overflow (); @@ -1203,11 +1216,20 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, while (n > 0) { ptrdiff_t val; + +#ifdef REL_ALLOC + /* See commentary above for the reasons for inhibiting + buffer text relocation here. */ + r_alloc_inhibit_buffer_relocation (1); +#endif val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, pos_byte - BEGV_BYTE, lim_byte - pos_byte, (NILP (Vinhibit_changing_match_data) ? &search_regs : &search_regs_1), lim_byte - BEGV_BYTE); +#ifdef REL_ALLOC + r_alloc_inhibit_buffer_relocation (0); +#endif if (val == -2) { matcher_overflow (); |