Nick Ing-Simmons <[EMAIL PROTECTED]> writes:
>While (on the other machine) Tk804 seems happy-ish, on 
>this laptop I am attempting to catch up on my mail 
>using bleadperl + UTF8-aware tkmail but non Unicode Tk800.
>
>It seems to be discovering a snag.
>
>When I try and read Autrijus Tang's latest posting to 
>perl-unicode with that I get a malloc related segfault:
>
>
>Note that in _this_ case use of tkmail is using fallbacks - so I suspect 
>(no proof yet) that "new" fallback insert can buffer-overrun, and so destroy 
>the malloc data structures.

This looks suspicious:

Near line 181 of Encode.xs (tail of main while loop):

            /* settle variables when fallback */
            dlen = SvCUR(dst);
            d   = (U8*)SvPVX(dst) + dlen;
            s   = (U8*)SvPVX(src) + sdone;
            slen = tlen - sdone;
            break;

When calling do_encode() at top of loop dlen is supposed to be number
of bytes _available_ at d, and you have it as number of bytes _used_.
So if we have used most of it and then insert a fallback do_encode()
will zoom off the end of the SV.

I think (too late here for morning person like me to think well) that             

            d = (U8 *) SvEND(dst);
            dlen = SvLEN(dst) - ddone - 1;

is closer to correct ..


-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/

Reply via email to