You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Jason E. Stewart" <ja...@openinformatics.com> on 2001/10/08 01:54:06 UTC

IDDOMImplementation::createDocumentType hopelessly broken

Hey All,

When porting some code from DOM to IDOM I got a segfault when I called
IDDOMImplementation::createDocumentType(). 

Here's the offending bit of code:

    return new IDDocumentTypeImpl(0, qualifiedName, publicId, systemId);

It passes in a null pointer as the ownerDocument to:

IDDocumentTypeImpl::IDDocumentTypeImpl(IDOM_Document *ownerDoc,
                                   const XMLCh *qualifiedName,
                                   const XMLCh *pubId,
                                   const XMLCh *sysId)
	: fNode(ownerDoc),
    fParent(ownerDoc)
{
    IDDocumentImpl *docImpl = (IDDocumentImpl *)ownerDoc;
    publicId = docImpl->cloneString(pubId);
    systemId = docImpl->cloneString(sysId);

At which point it calls cloneString() which attempts to allocate
memory and assign it to the (NULL) ownerDocument ==> segfault.

This code is taken (nearly) verbatim from DOM, where it works because
memory management is handled differently.

How is this every supposed to work for IDOM? Before I create a
Document, I have to first create a DocumentType, but in order to have
one of those the memory must be allocated to an existing
Document...

Catch 22 ...

I would offer a patch but this is hopeless.

jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org