[xml] XPath fix



Hi.

Found a small bug in xmlXPathCastToString() in xpath.c
Had problems getting wierd results if the XPath result was a string (e.g.
"string('Hello')" = "ÝÝÝÝÝÝÝÝÝÝ)p)" )
Noticed that all other cases in xmlXPathCastToString() create a new string
apart from case XPATH_STRING, which just returns the stringval itself. As I
was already freeing the XPathObject results object, the memory was getting
trashed.
Fix just involves returning a duplicate of the string, and now you are
always responsible for freeing the string returned separately, regardless of
what type of result it is.

Line 3210 in xpath.c (version 2.4.18)
Replace

 case XPATH_STRING:
     return(val->stringval);

with

 case XPATH_STRING:
     ret=xmlStrdup(val->stringval);
     break;

(Sorry for not doing it as one of those proper patch things - need to learn
how to use CVS sometime...)

As a heads up, I'm working on a fix for one of the number expressions -
libxml returns 1 for the expression "5.46 mod 2.6". Apparently, according to
the xsl-list, it should return "0.26" (Something to do with Java doing
floating point mods, C only doing integer mods).

Richard



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




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