aboutsummaryrefslogtreecommitdiffstats
path: root/src/xml.c
diff options
context:
space:
mode:
authorEli Zaretskii2016-10-23 19:52:56 +0300
committerEli Zaretskii2016-10-23 19:52:56 +0300
commit71ca4f6a43bad06192cbc4bb8c7a2d69c179b7b0 (patch)
tree5408032b9c42392812a4ce04d8ba67f79594f882 /src/xml.c
parent1b3fc8ab4960a1e6cb8d614953f2ba252155ade0 (diff)
downloademacs-71ca4f6a43bad06192cbc4bb8c7a2d69c179b7b0.tar.gz
emacs-71ca4f6a43bad06192cbc4bb8c7a2d69c179b7b0.zip
Avoid relocating buffers while libxml2 reads its text
* src/xml.c (parse_region) [REL_ALLOC]: Freeze the ralloc arena while libxml2 reads the current buffer's text. (Bug#24764)
Diffstat (limited to 'src/xml.c')
-rw-r--r--src/xml.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/xml.c b/src/xml.c
index 1ef84bd917e..612b16c4c53 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -202,6 +202,11 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url,
202 } 202 }
203 203
204 buftext = BYTE_POS_ADDR (istart_byte); 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
205 if (htmlp) 210 if (htmlp)
206 doc = htmlReadMemory ((char *)buftext, 211 doc = htmlReadMemory ((char *)buftext,
207 iend_byte - istart_byte, burl, "utf-8", 212 iend_byte - istart_byte, burl, "utf-8",
@@ -214,6 +219,9 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url,
214 XML_PARSE_NONET|XML_PARSE_NOWARNING| 219 XML_PARSE_NONET|XML_PARSE_NOWARNING|
215 XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); 220 XML_PARSE_NOBLANKS |XML_PARSE_NOERROR);
216 221
222#ifdef REL_ALLOC
223 r_alloc_inhibit_buffer_relocation (0);
224#endif
217 /* If the assertion below fails, malloc was called inside the above 225 /* If the assertion below fails, malloc was called inside the above
218 libxml2 functions, and ralloc.c caused relocation of buffer text, 226 libxml2 functions, and ralloc.c caused relocation of buffer text,
219 so we could have read from unrelated memory. */ 227 so we could have read from unrelated memory. */