util/charset: Include final UTF‐16 code unit in length calculation loop
commit74a5a3b74e1388936307da9d06f4d1a816d7613f
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Tue, 14 Nov 2023 01:38:48 +0000 (14 14:38 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 15 Nov 2023 22:07:36 +0000 (15 22:07 +0000)
treee811d94854f72d7c6cadfc038b4dcace086c9965
parent516f35b5a114136eaae283a53a6281b9895e29ed
util/charset: Include final UTF‐16 code unit in length calculation loop

Change ‘<’ to ‘<=’ so that we check the final UTF‐16 code unit in our
search for the null terminator. This makes no difference to the result:
if we’ve reached the final code unit without finding a terminator, the
final code unit will be included in the length whether it is a null
terminator or not.

Why make this change? We’re about to factor out this loop into a new
function, utf16_len_n(), where including the final code unit *will*
matter.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/charset/util_unistr.c