aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2022-05-11 21:20:55 +0600
committerMichael Forney <mforney@mforney.org>2022-05-11 11:15:56 -0700
commitef3b6b33eba80b82ae3da1d8e322b531bfc99902 (patch)
tree55ce92c8dd1fc5286d14dd5f07ed20ea67a23359
parentfb00ba697821de4fb3d8d0dd44edfa5f4727d067 (diff)
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.
-rw-r--r--expr.c2
1 files changed, 1 insertions, 1 deletions
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;
}