diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gmalloc.c | 4 | ||||
| -rw-r--r-- | src/search.c | 4 | ||||
| -rw-r--r-- | src/xml.c | 19 |
3 files changed, 21 insertions, 6 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c index 33d424fe9af..6ca35ec5f15 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -35,10 +35,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 35 | #include <pthread.h> | 35 | #include <pthread.h> |
| 36 | #endif | 36 | #endif |
| 37 | 37 | ||
| 38 | #ifdef WINDOWSNT | ||
| 39 | #include <w32heap.h> /* for sbrk */ | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #ifdef emacs | 38 | #ifdef emacs |
| 43 | # include "lisp.h" | 39 | # include "lisp.h" |
| 44 | #endif | 40 | #endif |
diff --git a/src/search.c b/src/search.c index bcb5ee95edb..127a57ab1db 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -1226,6 +1226,8 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1226 | ? &search_regs : &search_regs_1), | 1226 | ? &search_regs : &search_regs_1), |
| 1227 | /* Don't allow match past current point */ | 1227 | /* Don't allow match past current point */ |
| 1228 | pos_byte - BEGV_BYTE); | 1228 | pos_byte - BEGV_BYTE); |
| 1229 | /* Update 'base' due to possible relocation inside re_search_2. */ | ||
| 1230 | base = current_buffer->text->beg; | ||
| 1229 | if (val == -2) | 1231 | if (val == -2) |
| 1230 | { | 1232 | { |
| 1231 | matcher_overflow (); | 1233 | matcher_overflow (); |
| @@ -1272,6 +1274,8 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1272 | (NILP (Vinhibit_changing_match_data) | 1274 | (NILP (Vinhibit_changing_match_data) |
| 1273 | ? &search_regs : &search_regs_1), | 1275 | ? &search_regs : &search_regs_1), |
| 1274 | lim_byte - BEGV_BYTE); | 1276 | lim_byte - BEGV_BYTE); |
| 1277 | /* Update 'base' due to possible relocation inside re_search_2. */ | ||
| 1278 | base = current_buffer->text->beg; | ||
| 1275 | if (val == -2) | 1279 | if (val == -2) |
| 1276 | { | 1280 | { |
| 1277 | matcher_overflow (); | 1281 | matcher_overflow (); |
| @@ -181,6 +181,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, | |||
| 181 | Lisp_Object result = Qnil; | 181 | Lisp_Object result = Qnil; |
| 182 | const char *burl = ""; | 182 | const char *burl = ""; |
| 183 | ptrdiff_t istart, iend, istart_byte, iend_byte; | 183 | ptrdiff_t istart, iend, istart_byte, iend_byte; |
| 184 | unsigned char *buftext; | ||
| 184 | 185 | ||
| 185 | xmlCheckVersion (LIBXML_VERSION); | 186 | xmlCheckVersion (LIBXML_VERSION); |
| 186 | 187 | ||
| @@ -200,18 +201,32 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, | |||
| 200 | burl = SSDATA (base_url); | 201 | burl = SSDATA (base_url); |
| 201 | } | 202 | } |
| 202 | 203 | ||
| 204 | buftext = BYTE_POS_ADDR (istart_byte); | ||
| 205 | #ifdef REL_ALLOC | ||
| 206 | /* Prevent ralloc.c from relocating the current buffer while libxml2 | ||
| 207 | functions below read its text. */ | ||
| 208 | r_alloc_inhibit_buffer_relocation (1); | ||
| 209 | #endif | ||
| 203 | if (htmlp) | 210 | if (htmlp) |
| 204 | doc = htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), | 211 | doc = htmlReadMemory ((char *)buftext, |
| 205 | iend_byte - istart_byte, burl, "utf-8", | 212 | iend_byte - istart_byte, burl, "utf-8", |
| 206 | HTML_PARSE_RECOVER|HTML_PARSE_NONET| | 213 | HTML_PARSE_RECOVER|HTML_PARSE_NONET| |
| 207 | HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| | 214 | HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| |
| 208 | HTML_PARSE_NOBLANKS); | 215 | HTML_PARSE_NOBLANKS); |
| 209 | else | 216 | else |
| 210 | doc = xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), | 217 | doc = xmlReadMemory ((char *)buftext, |
| 211 | iend_byte - istart_byte, burl, "utf-8", | 218 | iend_byte - istart_byte, burl, "utf-8", |
| 212 | XML_PARSE_NONET|XML_PARSE_NOWARNING| | 219 | XML_PARSE_NONET|XML_PARSE_NOWARNING| |
| 213 | XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); | 220 | XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); |
| 214 | 221 | ||
| 222 | #ifdef REL_ALLOC | ||
| 223 | r_alloc_inhibit_buffer_relocation (0); | ||
| 224 | #endif | ||
| 225 | /* If the assertion below fails, malloc was called inside the above | ||
| 226 | libxml2 functions, and ralloc.c caused relocation of buffer text, | ||
| 227 | so we could have read from unrelated memory. */ | ||
| 228 | eassert (buftext == BYTE_POS_ADDR (istart_byte)); | ||
| 229 | |||
| 215 | if (doc != NULL) | 230 | if (doc != NULL) |
| 216 | { | 231 | { |
| 217 | Lisp_Object r = Qnil; | 232 | Lisp_Object r = Qnil; |