# HG changeset patch # User William M. Brack <wbrack@src.gnome.org> # Date 1169665718 0 # Wed Jan 24 19:08:38 2007 +0000 # Node ID 749151840cdc75e984ce19b7e195c73ecb8ec468 # Parent a98cc4fa53113bf408561d7954e6ca674e3180ae added check for memory allocation error (bug #400242); fixed "type-punned * libxslt/pattern.c: added check for memory allocation error (bug #400242); fixed "type-punned pointer" warnings. * libxslt/xsltutils.c: added checks for memory allocation error (bug #400242) * restored NEWS, doc/EXSLT/downloads.html which mysteriously disappeared from svn svn path=/trunk/; revision=1419 diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Jan 24 11:05:28 PST 2007 William Brack <wbrack@mmm.com.hk> + + * libxslt/pattern.c: added check for memory allocation error + (bug #400242); fixed "type-punned pointer" warnings. + * libxslt/xsltutils.c: added checks for memory allocation error + (bug #400242) + * restored NEWS, doc/EXSLT/downloads.html which mysteriously + disappeared from svn + Wed Jan 17 14:20:18 CET 2007 Daniel Veillard <daniel@veillard.com> * configure.in doc/*: preparing release of 1.1.20 diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -10,6 +10,18 @@ to the CVS at http://cvs.gnome.org/viewcvs/libxslt/ code base.Those are the public releases made: +1.1.20: Jan 17 2007: + - Portability fixes: strict aliasing fix (Marcus Meissner), BSD portability + patches (Roland Illig) + - Bug fixes: Result Value Tree handling fix (William Brack), function + parameters fix (William), uninitialized variable (Kjartan Maraas), + empty text node handling (William), plugin support and test fixes (William), + fragment support fixes (William) + - Improvements: python stylesheet compare and transform context + access (Nic Ferrier), EXSLT string replace support (Joel Reed), + xsltproc better low level error handling (Mike Hommey and William) + + 1.1.19: Nov 29 2006: - Bug fixes: entities within attributes (William Brack), Python detection problem (Joseph Sacco), in-scope namespace bug (Mike Hommey), Result diff --git a/doc/EXSLT/downloads.html b/doc/EXSLT/downloads.html --- a/doc/EXSLT/downloads.html +++ b/doc/EXSLT/downloads.html @@ -20,7 +20,7 @@ <a href="mailto:Steve.Ball@zveno.com">Steve Ball</a> provides <a href="http://www.zveno.com/open_source/libxml2xslt.html">Mac Os X binaries</a>.</p><p><a name="Contribs" id="Contribs">Contribs:</a></p><p>I do accept external contributions, especially if compiling on another platform, get in touch with me to upload the package. I will keep them in the -<a href="ftp://xmlsoft.org/contribs/">contrib directory</a></p><p>Libxslt is also available from CVS:</p><ul><li><p>The <a href="http://cvs.gnome.org/bonsai/rview.cgi?cvsroot=/cvs/gnome&dir=libxslt">Gnome +<a href="ftp://xmlsoft.org/contribs/">contrib directory</a></p><p>Libxslt is also available from CVS:</p><ul><li><p>The <a href="http://cvs.gnome.org/bonsai/rview.cgi?cvsroot=/cvs/gnome">Gnome CVS base</a>. Check the <a href="http://developer.gnome.org/tools/cvs.html">Gnome CVS Tools</a> page; the CVS module is <b>libxslt</b>.</p> </li> diff --git a/libxslt/pattern.c b/libxslt/pattern.c --- a/libxslt/pattern.c +++ b/libxslt/pattern.c @@ -142,7 +142,7 @@ cur = (xsltCompMatchPtr) xmlMalloc(sizeof(xsltCompMatch)); if (cur == NULL) { xsltTransformError(NULL, NULL, NULL, - "xsltNewCompMatch : malloc failed\n"); + "xsltNewCompMatch : out of memory error\n"); return(NULL); } memset(cur, 0, sizeof(xsltCompMatch)); @@ -2066,7 +2066,12 @@ int xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, const xmlChar *mode, const xmlChar *modeURI) { - xsltCompMatchPtr pat, list, *top = NULL, next; + xsltCompMatchPtr pat, list, next; + /* + * 'top' will point to style->xxxMatch ptr - declaring as 'void' + * avoids gcc 'type-punned pointer' warning. + */ + void **top = NULL; const xmlChar *name = NULL; float priority; /* the priority */ @@ -2076,6 +2081,8 @@ priority = cur->priority; pat = xsltCompilePatternInternal(cur->match, style->doc, cur->elem, style, NULL, 1); + if (pat == NULL) + return(-1); while (pat) { next = pat->next; pat->next = NULL; @@ -2097,24 +2104,24 @@ if (pat->steps[0].value != NULL) name = pat->steps[0].value; else - top = (xsltCompMatchPtr *) &(style->attrMatch); + top = &(style->attrMatch); break; case XSLT_OP_CHILD: case XSLT_OP_PARENT: case XSLT_OP_ANCESTOR: - top = (xsltCompMatchPtr *) &(style->elemMatch); + top = &(style->elemMatch); break; case XSLT_OP_ROOT: - top = (xsltCompMatchPtr *) &(style->rootMatch); + top = &(style->rootMatch); break; case XSLT_OP_KEY: - top = (xsltCompMatchPtr *) &(style->keyMatch); + top = &(style->keyMatch); break; case XSLT_OP_ID: /* TODO optimize ID !!! */ case XSLT_OP_NS: case XSLT_OP_ALL: - top = (xsltCompMatchPtr *) &(style->elemMatch); + top = &(style->elemMatch); break; case XSLT_OP_END: case XSLT_OP_PREDICATE: @@ -2130,20 +2137,20 @@ if (pat->steps[0].value != NULL) name = pat->steps[0].value; else - top = (xsltCompMatchPtr *) &(style->piMatch); + top = &(style->piMatch); break; case XSLT_OP_COMMENT: - top = (xsltCompMatchPtr *) &(style->commentMatch); + top = &(style->commentMatch); break; case XSLT_OP_TEXT: - top = (xsltCompMatchPtr *) &(style->textMatch); + top = &(style->textMatch); break; case XSLT_OP_ELEM: case XSLT_OP_NODE: if (pat->steps[0].value != NULL) name = pat->steps[0].value; else - top = (xsltCompMatchPtr *) &(style->elemMatch); + top = &(style->elemMatch); break; } if (name != NULL) { diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c --- a/libxslt/xsltutils.c +++ b/libxslt/xsltutils.c @@ -2098,13 +2098,17 @@ xpathCtxt = XSLT_CCTXT(style)->xpathCtxt; xpathCtxt->doc = style->doc; } else - xpathCtxt = xmlXPathNewContext(style->doc); + xpathCtxt = xmlXPathNewContext(style->doc); #else xpathCtxt = xmlXPathNewContext(style->doc); #endif + if (xpathCtxt == NULL) + return NULL; xpathCtxt->dict = style->dict; } else { xpathCtxt = xmlXPathNewContext(NULL); + if (xpathCtxt == NULL) + return NULL; } /* * Compile the expression.