summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-10-18 21:30:41 +0100
committerNicholas Clark <nick@ccl4.org>2009-10-18 22:10:36 +0100
commite0ea5e2d50a479e160d39f481e02abd7c0c9cf91 (patch)
treefb57ba0ad27123ca5845fb62789f53338a1dbeb7 /utf8.c
parent30685b5659009a95642202219acc6ded18f74dbc (diff)
downloadperl-e0ea5e2d50a479e160d39f481e02abd7c0c9cf91.tar.gz
utf16_to_utf8_reversed() should croak early when passed an odd byte length.
Rather than transposing n + 1 bytes, including 1 it was not passed, before calling utf16_to_utf8() and having that croak. e 69422~
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index 7b7fd5712f..455078d582 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1020,6 +1020,10 @@ Perl_utf16_to_utf8_reversed(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen)
PERL_ARGS_ASSERT_UTF16_TO_UTF8_REVERSED;
+ if (bytelen & 1)
+ Perl_croak(aTHX_ "panic: utf16_to_utf8_reversed: odd bytelen %"UVuf,
+ (UV)bytelen);
+
while (s < send) {
const U8 tmp = s[0];
s[0] = s[1];