]> granicus.if.org Git - php/commit
Remove useless validity check when converting UTF-16LE -> wchar
authorAlex Dowad <alexinbeijing@gmail.com>
Sun, 6 Sep 2020 10:09:02 +0000 (12:09 +0200)
committerAlex Dowad <alexinbeijing@gmail.com>
Tue, 13 Oct 2020 04:12:37 +0000 (06:12 +0200)
commitaabbee23187af5590424b2e291fb26d62ef8ddf0
treef77075d6d18649e545abac44c7e8a5fb642ff135
parentf474e5502ce8ea2ddcd847b2cc7b09ca827623f6
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.
ext/mbstring/libmbfl/filters/mbfilter_utf16.c