[xml] null pointer access in htmlCreateDocParserCtxt()



Hello,

I just want to signal a problem in htmlCreateDocParserCtxt.

If "htmlCreateMemoryParserCtxt" returns a NULL context and the encoding parameter is not null, htmlCreateDocParserCtxt wil crash when it try to read "ctxt->input->encoding".

This append for example when the cur parameter is an empty string.

And about the htmlCreateDocParserCtxt function declaratin, is the flag ATTRIBUTE_UNUSED relevant ?


static htmlParserCtxtPtr
htmlCreateDocParserCtxt(const xmlChar *cur,
                        const char *encoding ATTRIBUTE_UNUSED) {
  int len;
  htmlParserCtxtPtr ctxt;

  if (cur == NULL)
    return(NULL);
  len = xmlStrlen(cur);
  ctxt = htmlCreateMemoryParserCtxt((char *)cur, len);

  if (encoding != NULL) {
    xmlCharEncoding enc;
    xmlCharEncodingHandlerPtr handler;

    if (ctxt->input->encoding != NULL)
            xmlFree((xmlChar *) ctxt->input->encoding);
    ctxt->input->encoding = xmlStrdup((const xmlChar *) encoding);


Jean-Daniel Dupas




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]