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 "Heeg, Michael" <He...@fev.de> on 2004/08/17 13:14:38 UTC

Newbie needs help -- XMLString::transcode crashes for some reason

Hi everybody,

I am getting crazy about a (small?) problem. I have created a class
"MyClass" which contains a method called "DOMCreateNewDOMDocument" (see code
extract below). This method should create a new DOMDocument, which can be
processed. The method works fine when called the first time, but the second
call leads to a crash when executing the "xchImpl =
XMLString::transcode("Range");" command. 

Do I have to delete or reset the DOMDocument or the DOMImplementation after
the first usage?
Can anybody help me????

Regards,
Michael



bool MyClass::DOMCreateNewDOMDocument( DOMDocument* &pDomDoc,
	
TMM_String strRootNodeName,
	
TMM_String strXSLTReference,
	
CStringArray &straNamespacePrefixes,
	
CStringArray &straNamespaceURIs,
	
TMM_String strSchemaPath,
	
TMM_Bool bUseNamespace,
	
TMM_Bool bAddDefaultXSINamespace)
{
	TMM_Bool bResult;
	TMM_String strTemp;

	//create new DOM implementation
	XMLCh* xchImpl;
//fixme
	xchImpl = XMLString::transcode("Range");
//fixme
	DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(xchImpl);
....
....
	return bResult;
}

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


Re: Newbie needs help -- XMLString::transcode crashes for some reason

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Tue, 2004-08-17 at 23:14, Heeg, Michael wrote:
> Hi everybody,
> 
> I am getting crazy about a (small?) problem. I have created a class
> "MyClass" which contains a method called "DOMCreateNewDOMDocument" (see code
> extract below). This method should create a new DOMDocument, which can be
> processed. The method works fine when called the first time, but the second
> call leads to a crash when executing the "xchImpl =
> XMLString::transcode("Range");" command. 
> 
> Do I have to delete or reset the DOMDocument or the DOMImplementation after
> the first usage?
> Can anybody help me????
> 
> Regards,
> Michael
> 
> 
> 
> bool MyClass::DOMCreateNewDOMDocument( DOMDocument* &pDomDoc,
> 	
> TMM_String strRootNodeName,
> 	
> TMM_String strXSLTReference,
> 	
> CStringArray &straNamespacePrefixes,
> 	
> CStringArray &straNamespaceURIs,
> 	
> TMM_String strSchemaPath,
> 	
> TMM_Bool bUseNamespace,
> 	
> TMM_Bool bAddDefaultXSINamespace)
> {
> 	TMM_Bool bResult;
> 	TMM_String strTemp;
> 
> 	//create new DOM implementation
> 	XMLCh* xchImpl;
> //fixme
> 	xchImpl = XMLString::transcode("Range");
> //fixme
> 	DOMImplementation* impl =
> DOMImplementationRegistry::getDOMImplementation(xchImpl);
> ....
> ....
> 	return bResult;
> }

Hi Michael,

I'm no xerces expert but, as no-one else has spoken up, here's my 2
cents.

I think it unlikely that the problem is in XMLString::transcode. The
XMLString class is reasonably simple (even including the transcoding
stuff). And it has no relation whatsoever to the existence or otherwise
of any DOMDocument or DOMImplementation objects AFAIK.

Maybe you have a bug that is causing some kind of memory overwrite
between the two calls to your DOMCreateNewDOMDocument method?

By the way, are you sure you're calling XMLPlatformUtils::Initialize
before you use any xerces functionality?

NB: I believe you have a memory leak in your code. XMLString::transcode
returns an allocated buffer that the caller must deallocate using
delete[] or XMLString::release.

Regards,

Simon


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