Re: Memory access bug in XMLString2Perl()

[email protected] (Jason E. Stewart)
Newsgroups gmane.text.xml.xerces-p.devel
Message-ID <[email protected]>
Chris Cheung <[email protected]> writes:

> On 20 Dec 2003, Jason E. Stewart wrote:
> 
> > > The memory to malloc should be (length * UTF8_MAXLEN + 1):
> > > 
> > >   XMLByte* res = new XMLByte[length * UTF8_MAXLEN + 1];          // output 
> > > 
> > > so that the memory for the ending '\0' is not missed.
> > 
> > Does changing this make a difference? I would be surprised - the call
> > to transcode to gives the *maximum possible length* for the buffer,
> > and returns the *actual* length used. Does changing this make valgrind
> > happy? I've got no objection to adding this to the code, I'm just
> > curious. 
> 
> Yes. After I changed the length, recompile and perform the same test, the
> error message from valgrind disappear. 

Ok, thanks Chris. 

> Will this issue be fixed in the next release?

Sure, I'll add the fix. Did the change affect the torrential memory leaks
that XML-Xerces has? Has valgrind identified any other sources where
the memorly leaks can be coming from? It is *ultra-critical* to get
those fixed as soon as possible.

Cheers,
jas.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.