diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-10-18 21:55:52 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-10-18 22:10:36 +0100 |
commit | 01ea242be7d23d3bfac7a37c0cdfaec0a8eb7e33 (patch) | |
tree | e6fd4877d2901d78e1548663670f966a414c07e4 /ext | |
parent | e0ea5e2d50a479e160d39f481e02abd7c0c9cf91 (diff) | |
download | perl-01ea242be7d23d3bfac7a37c0cdfaec0a8eb7e33.tar.gz |
utf16_to_utf8() should croak if the buffer ends without the second surrogate.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/XS-APItest/t/utf16_to_utf8.t | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/XS-APItest/t/utf16_to_utf8.t b/ext/XS-APItest/t/utf16_to_utf8.t index 83add20a27..3f6f798a32 100644 --- a/ext/XS-APItest/t/utf16_to_utf8.t +++ b/ext/XS-APItest/t/utf16_to_utf8.t @@ -54,3 +54,10 @@ like($@, qr/^panic: utf16_to_utf8_reversed: odd bytelen 1 at/, 'Odd byte length panics'); is($got, undef, 'hence eval returns undef'); is($in, "NA", 'and input unchanged'); + +$in = "\xD8\0\xDC\0"; +$got = eval {utf16_to_utf8($in, 2)}; +like($@, qr/^Malformed UTF-16 surrogate at/, 'Lone surrogate croaks'); +(ok(!defined $got, 'hence eval returns undef')) or + diag(join ', ', map {ord $_} split //, $got); + |