On Tue, 03 Jun 2008, Szakáts Viktor wrote:
Hi Viktor,
> 2008-06-03 01:31 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
> * source/vm/extend.c
> ! hb_storclen_buffer() fixed to free the passed buffer
> in case it couldn't be stored. This situation was
> easy to miss and difficult to detect for the caller,
> and it might cause leaks.
We cannot leave it in such form because now we have real problem.
So far caller could check the return value from hb_storclen_buffer()
and free the pointer when it was 0, f.e.:
if( !hb_storclen_buffer( szText, ulLen, 1 ) )
hb_xfree( szText );
And there was no memory leak for such code at all.
Now it's not possible because hb_arraySetCPtr() may return FALSE
and we have real memory leak.
This modification should be reverted or we should update all other
functions like hb_storptrGC(), hb_arraySetCPtr(), hb_arraySetPtrGC(),
etc. to keep compatible behavior instead of create exceptions.
I do not know if it's good idea because it will forbid to make
code like:
if( !hb_storclen_buffer( szText, ulLen, 1 ) )
{
if( !hb_storclen_buffer( szText, ulLen, 2 ) )
{
hb_retclen_buffer( szText, ulLen );
}
}
I would like to hear other developers opinion too.
best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour