Lisp_Object result = Qnil;
const char *burl = "";
ptrdiff_t istart, iend, istart_byte, iend_byte;
+ unsigned char *buftext;
xmlCheckVersion (LIBXML_VERSION);
burl = SSDATA (base_url);
}
+ buftext = BYTE_POS_ADDR (istart_byte);
if (htmlp)
- doc = htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte),
+ doc = htmlReadMemory ((char *)buftext,
iend_byte - istart_byte, burl, "utf-8",
HTML_PARSE_RECOVER|HTML_PARSE_NONET|
HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR|
HTML_PARSE_NOBLANKS);
else
- doc = xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte),
+ doc = xmlReadMemory ((char *)buftext,
iend_byte - istart_byte, burl, "utf-8",
XML_PARSE_NONET|XML_PARSE_NOWARNING|
XML_PARSE_NOBLANKS |XML_PARSE_NOERROR);
+ /* If the assertion below fails, malloc was called inside the above
+ libxml2 functions, and ralloc.c caused relocation of buffer text,
+ so we could have read from unrelated memory. */
+ eassert (buftext == BYTE_POS_ADDR (istart_byte));
+
if (doc != NULL)
{
Lisp_Object r = Qnil;