From 77849f1aa55ccf8b7c395256ce33a0a277c30771 Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Wed, 24 Jan 2007 19:08:38 +0000 Subject: [PATCH] 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 --- ChangeLog | 9 +++++++++ NEWS | 12 ++++++++++++ doc/EXSLT/downloads.html | 2 +- libxslt/pattern.c | 29 ++++++++++++++++++----------- libxslt/xsltutils.c | 6 +++++- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3d923a..2d2de3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Jan 24 11:05:28 PST 2007 William Brack + + * 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 * configure.in doc/*: preparing release of 1.1.20 diff --git a/NEWS b/NEWS index 24933fc..dcf3533 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,18 @@ ChangeLog.html 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 index 88295e5..223ecef 100644 --- a/doc/EXSLT/downloads.html +++ b/doc/EXSLT/downloads.html @@ -20,7 +20,7 @@ provides Solaris binaries. Steve Ball provides Mac Os X binaries.

Contribs:

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 -contrib directory

Libxslt is also available from CVS:

  • The Gnome +contrib directory

    Libxslt is also available from CVS:

    • The Gnome CVS base. Check the Gnome CVS Tools page; the CVS module is libxslt.

    • diff --git a/libxslt/pattern.c b/libxslt/pattern.c index c3433c9..03f7122 100644 --- a/libxslt/pattern.c +++ b/libxslt/pattern.c @@ -142,7 +142,7 @@ xsltNewCompMatch(void) { 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 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc, 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 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, 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 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, 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 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, 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 index 7f37fdc..f300769 100644 --- a/libxslt/xsltutils.c +++ b/libxslt/xsltutils.c @@ -2098,13 +2098,17 @@ xsltXPathCompile(xsltStylesheetPtr style, const xmlChar *str) { 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. -- 2.7.4