summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-10-18 22:09:14 +0100
committerNicholas Clark <nick@ccl4.org>2009-10-18 22:10:36 +0100
commit52b9aa85a8c28ddc591b0a7f2b1f8c729075d9a1 (patch)
tree3b59c7ff5092a87d0e5e887db9e18410b7657e98 /utf8.c
parentdbde19516d139ef4237fc56ac1a14665a9f13c0b (diff)
downloadperl-52b9aa85a8c28ddc591b0a7f2b1f8c729075d9a1.tar.gz
In utf16_to_utf8(), fix off-by-one errors for the range of valid surrogates.
Both high ends were one too low.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/utf8.c b/utf8.c
index 3e4451b10a..3de02ed4f3 100644
--- a/utf8.c
+++ b/utf8.c
@@ -985,13 +985,13 @@ Perl_utf16_to_utf8(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen)
*d++ = (U8)(( uv & 0x3f) | 0x80);
continue;
}
- if (uv >= 0xd800 && uv < 0xdbff) { /* surrogates */
+ if (uv >= 0xd800 && uv <= 0xdbff) { /* surrogates */
if (p >= pend) {
Perl_croak(aTHX_ "Malformed UTF-16 surrogate");
} else {
UV low = (p[0] << 8) + p[1];
p += 2;
- if (low < 0xdc00 || low >= 0xdfff)
+ if (low < 0xdc00 || low > 0xdfff)
Perl_croak(aTHX_ "Malformed UTF-16 surrogate");
uv = ((uv - 0xd800) << 10) + (low - 0xdc00) + 0x10000;
}