This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
XS::APItest: Flatten src for utf16_to_utf8_reversed
authorFather Chrysostomos <sprout@cpan.org>
Thu, 12 Dec 2013 23:26:01 +0000 (15:26 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 17 Jan 2014 01:58:37 +0000 (17:58 -0800)
utf16_to_utf8_reversed (the C function) modifies its input, so the XS
function of the same name should flatten the input to avoid modifying
shared buffers.

Brought to you by PERL_DEBUG_READONLY_COW.

ext/XS-APItest/APItest.xs

index 1b8ec3f..f8fc1bf 100644 (file)
@@ -2480,6 +2480,7 @@ utf16_to_utf8 (sv, ...)
        SV *dest;
        I32 got; /* Gah, badly thought out APIs */
     CODE:
+       if (ix) (void)SvPV_force_nolen(sv);
        source = (U8 *)SvPVbyte(sv, len);
        /* Optionally only convert part of the buffer.  */      
        if (items > 1) {