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>
{
size_t len;
- for (len = 0; (len+2 < n) && SVAL(src, len); len += 2) ;
+ for (len = 0; (len+2 <= n) && SVAL(src, len); len += 2) ;
if (len+2 <= n) {
len += 2;