From ef3b6b33eba80b82ae3da1d8e322b531bfc99902 Mon Sep 17 00:00:00 2001 From: NRK Date: Wed, 11 May 2022 21:20:55 +0600 Subject: expr: fix erroneous comparison as long as `size_t`'s conversion rank is >= `int` this check would work out fine. but in case size_t happens to be less than int (which I believe is valid under the C standard) then comparison will take place in `signed int` and the operand `-1` will not get implicitly converted to SIZE_MAX. explicitly cast it to size_t to avoid such issues. --- expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expr.c b/expr.c index dc11aec..83e80f7 100644 --- a/expr.c +++ b/expr.c @@ -403,7 +403,7 @@ decodechar(const char *src, uint_least32_t *chr, bool *hexoct, const char *desc, } } else { n = utf8dec(&c, s, 4); - if (n == -1) + if (n == (size_t)-1) error(loc, "%s contains invalid UTF-8", desc); s += n; } -- cgit v1.2.3