Re: [xml] xmlschemas.c patch



Hi Daniel,

On 19/01/2004, at 9:05, Daniel Veillard wrote:
On Mon, Jan 19, 2004 at 07:08:30AM +1100, Steve Ball wrote:
Found a bug in xmlschemas.c last week, a small patch is attached.
   Hum, thanks but I think both were fixed in CVS some time ago.

One of the bugs, initialising the dictionary, has been fixed, but there
remains the second bug.

This fixes two problems when compiling a XML Schema from an in-memory
xmlDocPtr structure.  The document is copied from the parser context
and the dictionary is initialised.

 I'm very dubious about the xmlCopyDoc(ctxt->doc, 1) sounds like
a giant memory leak. Can you check the CVs version and see if your problem
is fixed instead ?

The xmlSchemaParserCtxt as well as the xmlSchema both assume that
they have a copy of the schema document.  xmlSchemaFreeParserCtxt and
xmlSchemaFree both execute xmlFreeDoc, hence the current code will
free the document twice.

xmlSchemaParse modifies its copy of the document, so it really does need its own
copy of the document.

I can see the following alternatives:

1. xmlSchemaParserCtxt must copy the document, which will consume additional memory. This also means that subsequent changes to the document will not be seen if the same parser
context is used to create another compiled schema.

2. Set ctxt->doc = NULL after copying the document in xmlSchemaParse. This would make
the parser context non-reusable.

3. Don't have xmlSchemaFreeParserCtxt free the document. It is up to the application
to free the document.

Now that I've looked into it alot further I see no reason why xmlSchemaFreeParserCtxt
should free the document.

Your thoughts?

Cheers,
Steve Ball


Steve Ball            |   XSLT Standard Library   | Training & Seminars
Zveno Pty Ltd         |     Web Tcl Complete      |   XML XSL Schemas
http://www.zveno.com/ |      TclXML TclDOM        | Tcl, Web Development
Steve Ball zveno com  +---------------------------+---------------------
Ph. +61 2 6242 4099   |   Mobile (0413) 594 462   | Fax +61 2 6242 4099




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]