RE: [xslt] small patch for xsltFreeStylePreComps()
- From: "Buchcik, Kasimier" <k buchcik 4commerce de>
- To: <veillard redhat com>, "The Gnome XSLT library mailing-list" <xslt gnome org>
- Cc:
- Subject: RE: [xslt] small patch for xsltFreeStylePreComps()
- Date: Fri, 5 May 2006 18:22:36 +0200
Hi Aleksey,
Missed that Daniel was deferring to me, when I read your mail
the first time.
The only thing that we need additionally to take care of, is
the order of freeing: in xsltFreeStylesheet() the documents
of 1 stylesheet-level are freed before the compiled information
is freed. So we need to reverse that order.
I've added the patch to my local changed and hope to commit
this today with all the refactored stuff (still IFDEFed out
with XSLT_REFACTORED).
Regards,
Kasimier
> -----Original Message-----
> From: xslt-bounces gnome org [mailto:xslt-bounces gnome org]
> On Behalf Of Daniel Veillard
>
> On Tue, May 02, 2006 at 07:54:14PM -0700, Aleksey Sanin wrote:
> > Hello, All!
> >
> > I run into a small problem with re-using XSLT stylesheet document
> > in the following scenario (the same xmlDocPtr is used for more
> > than one stylesheet):
> >
> > xmlDocPtr xslt_doc;
> > xsltStylesheetPtr stylesheet;
> >
> > xslt_doc = ... ; /* Get xslt doc somehow */
> > ...
> >
> > /* use doc stylesheet first time */
> > stylesheet = xsltParseStylesheetDoc(xslt_doc);
> > out1 = xsltApplyStylesheet(stylesheet, in1);
> > ... /* consume out1 */
> > xsltFreeStylesheet(stylesheet);
> >
> > ...
> >
> > /* use doc stylesheet first time */
> > stylesheet = xsltParseStylesheetDoc(xslt_doc);
> > out2 = xsltApplyStylesheet(stylesheet, in2); <--- crash
> > ... /* consume out2 */
> > xsltFreeStylesheet(stylesheet);
> >
> >
> > I understand that this is probably a corner case scenario since
> > it is much better to do not re-create xsltStylesheetPtr second
> > time. But at the moment it is not possible to do in my case.
> >
> > It turns out that the crash is caused by invalid pointer in
> > "psvi" member of xmlNodePtr. The actual data structure was freed
> > by the first xsltFreeStylesheet() call but the "psvi" pointer
> > was still pointed to it. The attached patch fixes the problem by
> > making sure that we cleanup this "psvi" pointer when we destroy
> > the data structure.
> >
> > I would appreciate if someone can take a look at the patch and
> > check that it is not doing something stupid :)
>
> stylesheet compilation modifies the input doc, a lot ...
> The patch may make sense, but you should really reparse the input.
> Or find a way to reuse the compiled stylesheet.
>
> > diff -ur libxslt/preproc.c libxslt/preproc.c
> > --- libxslt/preproc.c 2005-03-29 05:12:59.000000000 -0800
> > +++ libxslt/preproc.c 2006-05-02 19:09:33.682620800 -0700
> > @@ -1321,6 +1321,8 @@
> > cur = style->preComps;
> > while (cur != NULL) {
> > next = cur->next;
> > + if(cur->inst != NULL)
> > + cur->inst->psvi = NULL;
> > if (cur->type == XSLT_FUNC_EXTENSION)
> > cur->free(cur);
> > else
>
> I defer to Kasimier for this since he's playing with this
> at the moment.
[...]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]