Re: [xml] Possible 64-bit issues in xml 2.9.2



On 10/11/2015 22:04, Bruce Dawson wrote:
While building 64-bit Chromium with VC++ 2015 Update 1 I noticed a significant
number of pointer truncation warnings in libxml, especially in xpath.c. A
typical warning is:

warning C4311: 'type cast': pointer truncation from 'xmlChar *' to 'long'

which triggers on the last two lines of this block:

case XML_ELEMENT_NODE:
     if (node2->type == XML_ELEMENT_NODE) {
if ((0 > (long) node1->content) && /* TODO: Would a != 0 suffice here? */
     (0 > (long) node2->content) &&

The intent is not entirely clear but if these are supposed to be NULL checks
then they could easily give the wrong result.

Just to clarify: The values stored in node->content are actually integers used to speed up node comparisons. See xmlXPathOrderDocElems:

/**
 * xmlXPathOrderDocElems:
 * @doc:  an input document
 *
 * Call this routine to speed up XPath computation on static documents.
 * This stamps all the element nodes with the document order
 * Like for line information, the order is kept in the element->content
 * field, the value stored is actually - the node number (starting at -1)
 * to be able to differentiate from line numbers.
 *
 * Returns the number of elements found in the document or -1 in case
 *    of error.
 */

This comment indicates that other parts of libxml2 use the content field to store line numbers.

Nick



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