XMLString::release uses 'delete' even when MemoryManager is specified in
XMLString::transcode().
------------------------------------------------------------------------------------------------
Key: XERCESC-1301
URL: http://nagoya.apache.org/jira/browse/XERCESC-1301
Project: Xerces-C++
Type: Bug
Components: Utilities
Versions: 2.4.0
Environment: Windows XP, MS Visual C++ 7.0.
Reporter: Kode Charlie
The problem is this:
0. Specify a MemoryManager to XMLString::transcode().
1. Call XMLString::release() on the XMLCh* you obtained in step (0).
2. Observe that an exception occurs.
BoundsChecker shows that XMLString::release() is still calling
'delete' on the XMLCh**, even though we have specified our own
(de)allocation with the MemoryManager.
The code below captures the problem:
class TinyMemoryManager : public MemoryManager {
void *allocate (size_t size)
{
void *retval = malloc (size);
return retval;
}
void deallocate (void *p)
{
free (p);
}
};
static TinyMemoryManager *s_tmmgr = NULL;
class XStr
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XStr(const char* const toTranscode)
{
// Call the private transcoding method
fUnicodeForm = XMLString::transcode (toTranscode, s_tmmgr);
}
~XStr()
{
XMLString::release(&fUnicodeForm);
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const XMLCh* unicodeForm() const
{
return fUnicodeForm;
}
private :
// -----------------------------------------------------------------------
// Private data members
//
// fUnicodeForm
// This is the Unicode XMLCh format of the string.
// -----------------------------------------------------------------------
XMLCh* fUnicodeForm;
};
int main (int argc, char *argv[])
{
s_tmmgr = new TinyMemoryManager();
XMLCh *ch = somethingGoesHereThatReturnsAnXMLCh();
if (XMLString::compareString (ch, X ("root"))) // Fatal exception here.
printf ("matched root\n");
return 1;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]