develooper Front page | perl.perl5.porters | Postings from October 2003

Re: find_encoding("UTF-16BE")->encode("abc") does not NUL-terminate

Thread Previous | Thread Next
From:
SADAHIRO Tomoyuki
Date:
October 7, 2003 08:42
Subject:
Re: find_encoding("UTF-16BE")->encode("abc") does not NUL-terminate
Message ID:
20031008004030.8012.BQW10602@nifty.com

> Gisle,
> 
> So while I promise to fix this "bug" in Encode::Unicode,  I want to fix 
> and tidy other stuff before $Encode::VERSION++.  So if you are 
> impatient, I would like you to have your MIME::Base64 take care of this.
> 
> After all, null-termination itself is moot w/ UTF-(16|32)(BE|LE)?.
> 
> > Regards,
> 
> Ditto.
> 
> Dan the Encode Maintainer

IIRC, SvCUR() returns length w/o \0 and SvGROW() needs +1 for \0.
(sorry I did not rebuilt Encode, please test it)

--- Unicode.xs~	Tue Sep 02 22:39:28 2003
+++ Unicode.xs	Wed Oct 08 00:34:06 2003
@@ -54,7 +54,7 @@
 void
 enc_pack(pTHX_ SV *result,STRLEN size,U8 endian,UV value)
 {
-    U8 *d = (U8 *)SvGROW(result,SvCUR(result)+size);
+    U8 *d = (U8 *)SvGROW(result,SvCUR(result)+size+1);
     switch(endian) {
     case 'v':
     case 'V':

Regards,
SADAHIRO Tomoyuki


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About