RE: [xslt] [BUG] Win32, xsltproc, libxml, libxslt, <xsl:include/>
- From: "Igor Zlatkovic" <izlatkovic daenet de>
- To: <xslt gnome org>
- Subject: RE: [xslt] [BUG] Win32, xsltproc, libxml, libxslt, <xsl:include/>
- Date: Wed, 8 May 2002 17:24:50 +0200
Hello,
The describe problem is an error in the libxslt code and affects all
platforms.
* The xsltParseStylesheetInclude function calls
xsltParseStylesheetProcess and gives it the pointer to the stylesheet.
* xsltParseStylesheetProcess fails and frees the memory associated with
the pointer it received as a parameter.
* xsltParseStylesheetInclude happily continues using the now invalid
pointer, and has no way of informing its caller that the stylesheet
memory has been freed.
The patch further below solves the problem by putting the memory release
burden on the back of whoever calls xsltParseStylesheetProcess. I am not
sure if that is the right way, therefore I shall not apply this patch to
the source until Daniel returns and confirms it. I shall however have
the patched binaries for Windows online later today.
Thanks!
Ciao
Igor
Index: xslt.c
===================================================================
RCS file: /cvs/gnome/libxslt/libxslt/xslt.c,v
retrieving revision 1.77
diff -c -r1.77 xslt.c
*** xslt.c 14 Apr 2002 13:35:23 -0000 1.77
--- xslt.c 8 May 2002 14:58:45 -0000
***************
*** 1878,1884 ****
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetProcess : empty stylesheet\n");
ret->doc = NULL;
! xsltFreeStylesheet(ret);
return(NULL);
}
xsltParseStylesheetExcludePrefix(ret, cur);
--- 1878,1885 ----
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetProcess : empty stylesheet\n");
ret->doc = NULL;
! /* Igor: Let the caller do that.
! xsltFreeStylesheet(ret); */
return(NULL);
}
xsltParseStylesheetExcludePrefix(ret, cur);
***************
*** 1906,1912 ****
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetProcess : document is not a
stylesheet\n");
ret->doc = NULL;
! xsltFreeStylesheet(ret);
return(NULL);
}
--- 1907,1914 ----
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetProcess : document is not a
stylesheet\n");
ret->doc = NULL;
! /* Igor: Let the caller do that.
! xsltFreeStylesheet(ret); */
return(NULL);
}
***************
*** 1930,1936 ****
template = xsltNewTemplate();
if (template == NULL) {
ret->doc = NULL;
! xsltFreeStylesheet(ret);
return(NULL);
}
template->next = ret->templates;
--- 1932,1939 ----
template = xsltNewTemplate();
if (template == NULL) {
ret->doc = NULL;
! /* Igor: Let the caller do that.
! xsltFreeStylesheet(ret); */
return(NULL);
}
template->next = ret->templates;
***************
*** 1962,1967 ****
--- 1965,1971 ----
xsltStylesheetPtr
xsltParseStylesheetDoc(xmlDocPtr doc) {
xsltStylesheetPtr ret;
+ xsltStylesheetPtr xsp;
if (doc == NULL)
return(NULL);
***************
*** 1972,1980 ****
ret->doc = doc;
xsltGatherNamespaces(ret);
! ret = xsltParseStylesheetProcess(ret, doc);
! return(ret);
}
/**
--- 1976,1986 ----
ret->doc = doc;
xsltGatherNamespaces(ret);
! xsp = xsltParseStylesheetProcess(ret, doc);
! if (xsp == NULL)
! xsltFreeStylesheet(ret);
! return(xsp);
}
/**
Index: imports.c
===================================================================
RCS file: /cvs/gnome/libxslt/libxslt/imports.c,v
retrieving revision 1.12
diff -c -r1.12 imports.c
*** imports.c 14 Apr 2002 13:35:23 -0000 1.12
--- imports.c 8 May 2002 14:58:45 -0000
***************
*** 129,134 ****
--- 129,135 ----
xmlChar *uriRef = NULL;
xmlChar *URI = NULL;
xsltDocumentPtr include;
+ xsltStylesheetPtr stylep;
if ((cur == NULL) || (style == NULL))
return;
***************
*** 160,167 ****
oldDoc = style->doc;
style->doc = include->doc;
! xsltParseStylesheetProcess(style, include->doc);
style->doc = oldDoc;
error:
if (uriRef != NULL)
--- 161,174 ----
oldDoc = style->doc;
style->doc = include->doc;
! stylep = xsltParseStylesheetProcess(style, include->doc);
style->doc = oldDoc;
+ if (stylep == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
+ xsltGenericError(xsltGenericErrorContext,
+ "xsl:include : unable to process %s\n", URI);
+ goto error;
+ }
error:
if (uriRef != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]