+Sun Jul 27 13:52:10 CEST 2008 Daniel Veillard <veillard@redhat.com>
+
+ * libxslt/xslt.c: avoid a quadratic behaviour when hitting duplicates
+ exclude-result-prefixes declarations, should fix #544906
+
Sat Jul 26 12:43:18 PST 2008 William Brack <wbrack@mmm.com.hk>
*configure.in: fixed option --with-debugger with patch from
*
* Push an excluded namespace name on the stack
*
- * Returns the new index in the stack or 0 in case of error
+ * Returns the new index in the stack or -1 if already present or
+ * in case of error
*/
static int
exclPrefixPush(xsltStylesheetPtr style, xmlChar * value)
{
+ int i;
+
if (style->exclPrefixMax == 0) {
style->exclPrefixMax = 4;
style->exclPrefixTab =
sizeof(style->exclPrefixTab[0]));
if (style->exclPrefixTab == NULL) {
xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
- return (0);
+ return (-1);
}
}
+ /* do not push duplicates */
+ for (i = 0;i < style->exclPrefixNr;i++) {
+ if (xmlStrEqual(style->exclPrefixTab[i], value))
+ return(-1);
+ }
if (style->exclPrefixNr >= style->exclPrefixMax) {
style->exclPrefixMax *= 2;
style->exclPrefixTab =
sizeof(style->exclPrefixTab[0]));
if (style->exclPrefixTab == NULL) {
xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
- return (0);
+ return (-1);
}
}
style->exclPrefixTab[style->exclPrefixNr] = value;
prefix);
if (style != NULL) style->warnings++;
} else {
+ if (exclPrefixPush(style, (xmlChar *) ns->href) >= 0) {
#ifdef WITH_XSLT_DEBUG_PARSING
- xsltGenericDebug(xsltGenericDebugContext,
- "exclude result prefix %s\n", prefix);
+ xsltGenericDebug(xsltGenericDebugContext,
+ "exclude result prefix %s\n", prefix);
#endif
- exclPrefixPush(style, (xmlChar *) ns->href);
- nb++;
+ nb++;
+ }
}
xmlFree(prefix);
}