[xml] patch: xpath.c



[re-posted using subscribed e-mail]

The namespaces xmlChar** array created in xpath.c ~ line 11255 is created of
the wrong size.  The following test case caused a crash on win32.  The problem
only occurred when a large number of namespaces were defined.

dyntest.xml : test case source
dyntest2.xsl : test case stylesheet
xpath.diff : patch 

- mark

Index: xpath.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xpath.c,v
retrieving revision 1.284
diff -c -r1.284 xpath.c
*** xpath.c     1 Apr 2005 13:11:52 -0000       1.284
--- xpath.c     2 May 2005 17:30:36 -0000
***************
*** 11252,11258 ****
        if (ctxt != NULL) {
            dict = ctxt->dict;
            if (ctxt->nsNr > 0) {
!               namespaces = xmlMalloc(2 * (ctxt->nsNr + 1));
                if (namespaces == NULL) {
                    xmlXPathErrMemory(ctxt, "allocating namespaces array\n");
                    return(NULL);
--- 11252,11258 ----
        if (ctxt != NULL) {
            dict = ctxt->dict;
            if (ctxt->nsNr > 0) {
!               namespaces = xmlMalloc(2 * (ctxt->nsNr + 1) * sizeof(xmlChar*));
                if (namespaces == NULL) {
                    xmlXPathErrMemory(ctxt, "allocating namespaces array\n");
                    return(NULL);
<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:ns2="http://something.com/ns1";
 xmlns:ns3="http://something.com/ns2";
 xmlns:ns4="http://something.com/ns3";
 xmlns:ns5="http://something.com/ns4";
 xmlns:ns6="http://something.com/ns5";
 xmlns:ns7="http://something.com/ns6";
 xmlns:ns8="http://something.com/ns7";
 xmlns:ns9="http://something.com/ns8";
 xmlns:ns10="http://something.com/ns9";
 xmlns:ns11="http://something.com/ns10";
 xmlns:ns12="http://something.com/ns11";
 xmlns:dyn="http://exslt.org/dynamic";
 exclude-result-prefixes="ns2 ns3 ns4 ns5 ns6 ns7 ns8 ns9 ns10 ns11 ns12 dyn"


<xsl:template match="/">
 <result>
         <xsl:value-of select="dyn:evaluate('/root/num')"/>
        </result>       
</xsl:template>

</xsl:stylesheet> 

<?xml version="1.0"?>
<root>
 <num>1</num>
</root>


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