mirror of
https://github.com/php/php-src.git
synced 2026-04-24 16:38:25 +02:00
Remove useless validity check when converting UTF-16LE -> wchar
The check ensures that the decoded codepoint is between 0x10000-0x10FFFF, which is the valid range which can be encoded in a UTF-16 surrogate pair. However, just looking at the code, it's obvious that this will be true. First of all, 0x10000 is added to the decoded codepoint on the previous line, so how could it be less than 0x10000? Further, even if the 20 data bits already decoded were 0xFFFFF (all ones), when you add 0x10000, it comes to 0x10FFFF, which is the very top of the valid range. So how could the decoded codepoint be more than 0x10FFFF? It can't.
This commit is contained in:
@@ -290,11 +290,7 @@ int mbfl_filt_conv_utf16le_wchar(int c, mbfl_convert_filter *filter)
|
||||
case 3:
|
||||
filter->status = 0;
|
||||
int n = filter->cache + ((c & 0x3) << 8) + 0x10000;
|
||||
if (n >= MBFL_WCSPLANE_SUPMIN && n < MBFL_WCSPLANE_SUPMAX) {
|
||||
CK((*filter->output_function)(n, filter->data));
|
||||
} else { /* illegal character */
|
||||
CK((*filter->output_function)((n & MBFL_WCSGROUP_MASK) | MBFL_WCSGROUP_THROUGH, filter->data));
|
||||
}
|
||||
CK((*filter->output_function)(n, filter->data));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user