summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-06-13 11:49:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-06-13 16:34:17 (GMT)
commit9dae4fe79f85dd0eaf41215bea76c68b65398fbc (patch)
treee6d017d7b63f0730eee15aa52def36f03067a23c /config.c
parent4fa42df972dc40fa3b50195ace838f2269da977a (diff)
downloadgit-9dae4fe79f85dd0eaf41215bea76c68b65398fbc.zip
git-9dae4fe79f85dd0eaf41215bea76c68b65398fbc.tar.gz
git-9dae4fe79f85dd0eaf41215bea76c68b65398fbc.tar.bz2
config: avoid calling `labs()` on too-large data type
The `labs()` function operates, as the initial `l` suggests, on `long` parameters. However, in `config.c` we tried to use it on values of type `intmax_t`. This problem was found by GCC v9.x. To fix it, let's just "unroll" the function (i.e. negate the value if it is negative). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/config.c b/config.c
index 296a6d9..01c6e9d 100644
--- a/config.c
+++ b/config.c
@@ -869,9 +869,9 @@ static int git_parse_signed(const char *value, intmax_t *ret, intmax_t max)
errno = EINVAL;
return 0;
}
- uval = labs(val);
+ uval = val < 0 ? -val : val;
uval *= factor;
- if (uval > max || labs(val) > uval) {
+ if (uval > max || (val < 0 ? -val : val) > uval) {
errno = ERANGE;
return 0;
}