Re: Memory problem when calling xmlBufferGrow/realloc (Re: [xml] Strange error depending on buffer size)

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@imag.fr)
Date: Fri Feb 16 2001 - 12:52:18 EST


On Fri, Feb 16, 2001 at 06:15:40PM +0100, Manuel Guesdon wrote:
>
> I've investigated deeply on the problem and it seems that realloc() call may produce a failure:
>
> When calling xmlCharEncInFunc, I have
> buffer 8124460 : content 8126aa0, base =3D 8126aa0, cur 5, use 40, size 4000
> xmlCharEncInFunc call xmlBufferGrow
> which call realloc (xmlReallocLoc) with ptr=0x8126aa0 size=8100
>
> in xmlReallocLoc p0x8126a80 before realloc() call
> After it is changed to 0x811ab28 and the new ptr is 0x811ab48 (instead of ptr=0x8126aa0).
>
> After that, I get a
> "base mismatch problem
> buffer 8124460 : content 811ab48, base =3D 8126aa0, cur 5, use 2020, size 8100
> "
> because content was changed but not base.
>
> If I reflect content change in base and cur after this, I get no more error.
>
> realloc() man page say "realloc(ptr) returns a pointer ... which ... may be different from ptr..."
>
> It's the case here and it break things.
>
> Now, I knwo the problem but I don't know enough libxml internal to provide a patch :-(

  Okay thanks for going deeper into it,
I have a better idea of what went wrong, I will try to fix it,

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com  | libxml Gnome XML toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri Feb 16 2001 - 14:43:41 EST