vim-patch:9.1.0022: Coverity complains about improper use of negative value (#27001)

Problem:  Coverity complains about improper use of negative value
Solution: Add a condition to validate that keytyped is larger or equal
          to 0

Apparently patch 9.1.0006 made it more explicit for Coverity, that the
TOLOWER_LOC() macros do not handle negative values properly. However,
that condition has always been there even before that, so add a
condition to verify that keytyped is indeed at least 0

closes: vim/vim#13824

49471963fe

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq 2024-01-13 13:23:42 +08:00 committed by GitHub
parent 786089013d
commit 89b0f5ac5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3170,7 +3170,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
} else {
// TODO(@brammool): multi-byte
if (keytyped == (int)(uint8_t)p[-1]
|| (icase && keytyped < 256
|| (icase && keytyped < 256 && keytyped >= 0
&& TOLOWER_LOC(keytyped) == TOLOWER_LOC((uint8_t)p[-1]))) {
char *line = get_cursor_pos_ptr();
assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);