summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2010-12-03 09:15:59 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-12-04 11:48:57 -0800
commit0072151e81aec9c504f2be93f0562f270ffac2c8 (patch)
tree3836518c256d33829ac94e695d5cce8cb77d0840 /utf8.h
parent14c287842e05fc65fd5d35b6ce06734e2fa161bc (diff)
downloadperl-0072151e81aec9c504f2be93f0562f270ffac2c8.tar.gz
utf8.h: Need to make sure macro result fits in byte
The UTF8_TWO_BYTE_HI_nocast() macro has an error in it, in that the START_MARK is larger than a byte, and only the last 8 bits of it are relevant. This hasn't caused a problem because the macro hasn't been called directly, but from other macros that make sure the result gets cast to a U8.
Diffstat (limited to 'utf8.h')
-rw-r--r--utf8.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/utf8.h b/utf8.h
index 8d12f8dba2..be14a94bb3 100644
--- a/utf8.h
+++ b/utf8.h
@@ -183,7 +183,7 @@ Perl's extended UTF-8 means we can have start bytes up to FF.
* bytes from an ordinal that is known to fit into two bytes; it must be less
* than 0x3FF to work across both encodings. */
/* Nocast allows these to be used in the case label of a switch statement */
-#define UTF8_TWO_BYTE_HI_nocast(c) UTF_TO_NATIVE(((c) >> UTF_ACCUMULATION_SHIFT) | UTF_START_MARK(2))
+#define UTF8_TWO_BYTE_HI_nocast(c) UTF_TO_NATIVE(((c) >> UTF_ACCUMULATION_SHIFT) | (0xFF & UTF_START_MARK(2)))
#define UTF8_TWO_BYTE_LO_nocast(c) UTF_TO_NATIVE(((c) & UTF_CONTINUATION_MASK) | UTF_CONTINUATION_MARK)
#define UTF8_TWO_BYTE_HI(c) ((U8) (UTF8_TWO_BYTE_HI_nocast(c)))