Hi,

> The string length is important!
> 
> -----------------------
> FUNC MAIN()
> LOCAL nI, cStr, cSSS
> 
> FOR nI := 1 TO 10000
> 
>    cStr := "aaaaaaaaaaaaaa
> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaa;aaaaaaaaaaaaaaaaa"
>    cSSS := ATREPL( ";", cStr, CHR(13)+CHR(10) )
> NEXT
> 
> RETURN
> -----------------------
> 
> hbmk2 test_atrepl.prg -lhbct -run
> (OS: KUbuntu x64 9.10, harbour: $Id: ChangeLog 14036 2010-03-02)
> 
> *** glibc detected *** /home/alx/bars/test/test_atrepl: free():
> invalid pointer: 0x00000000011af100 ***
> 
> 
> If you apply this patch, it works:
> 
> --- atrepl_orig.c       2010-03-02 19:59:21.706782700 +0300
> +++ atrepl.c    2010-03-02 19:59:32.336844828 +0300
> @@ -226,7 +226,8 @@
> 
>             if( pc == NULL )
>             {
> -               hb_retclen_buffer( pcRetStr, sRetStrLen );
> +               hb_retclen( pcRetStr, sRetStrLen );
> +               hb_xfree( pcRetStr );

hb_retclen_buffer() and hb_retclen() + hb_xfree() 
are always interchangable from the caller POV.

The real problem here is that caller doesn't 
allocate room for the ending zero byte.

Brgds,
Viktor

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to