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 bu...@apache.org on 2003/11/09 17:01:54 UTC
DO NOT REPLY [Bug 24535] New: -
Memory allocation problem in MemBufInputSource class
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24535>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24535
Memory allocation problem in MemBufInputSource class
Summary: Memory allocation problem in MemBufInputSource class
Product: Xerces-C++
Version: 2.3.0
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: Miscellaneous
AssignedTo: xerces-c-dev@xml.apache.org
ReportedBy: aryzhov@mera.ru
This code fails (with Segmentation fault on my system):
-------------------------------------------------------
char s[] = "<bla>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </bla>";
{
MemBufInputSource::MemBufInputSource xObj( (const XMLByte*)s,strlen
(s),"hello", true );
}
This code doesn't fail:
-----------------------
char s[] = "<bla>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </bla>";
XMLByte *p = new XMLByte[strlen(s)];
memcpy( (char*)p, s, strlen(s) );
{
MemBufInputSource::MemBufInputSource xObj( p,strlen(s),"hello", true );
}
The reason:
-----------
If last parameter of MemBufInputSource class constructor was true,
MemBufInputSource class destructor deallocates fSrcBytes buffer (member):
MemBufInputSource::~MemBufInputSource()
{
if (fAdopted)
delete [] (XMLByte*)fSrcBytes;
}
But this buffer is allocated nowhere. I think class contructor should allocate
it and fill it with data specified by first and second parameters.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org