This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
uvoffuni_to_utf8_flags() die if platform can't handle
authorKarl Williamson <public@khwilliamson.com>
Wed, 26 Jun 2013 21:40:53 +0000 (15:40 -0600)
committerKarl Williamson <khw@cpan.org>
Tue, 21 Oct 2014 15:26:50 +0000 (09:26 -0600)
commit9415f65901e09c7e3366bca00059a439e82fa804
tree734a3323e66d8d6fbe7170a577308e6f0fd5f7ab
parenta27ed9805e6767d92a9ba275f4379cd1f342cafe
uvoffuni_to_utf8_flags() die if platform can't handle

On non EBCDIC platforms currently any UV is encodable as UTF-8.  (This
would change if there were 128-bit words).  Thus, much code assumes that
nothing can go wrong when converting to UTF-8, and hence does no error
checking.

However, UTF-EBCDIC is only capable of representing code points below
2**32, so if there are 64-bit words, this function can fail.

Prior to this patch, there was no real overflow check, and garbage was
returned by this function if called with too large a number.

While not ideal, the easiest thing to do is to just die for such a
number, like we do for division by 0.  This involves changing only code
within this function, and not its many callers.
pod/perldiag.pod
t/lib/warnings/utf8
utf8.c