Commit d0fc848b5a0828055aa833fbd3fe90e6834f68f9

Thomas de Grivel 2023-07-09T17:28:03

fix buf_parse_s

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/libc3/buf_parse_s.c.in b/libc3/buf_parse_s.c.in
index 471a0f6..7adc0e5 100644
--- a/libc3/buf_parse_s.c.in
+++ b/libc3/buf_parse_s.c.in
@@ -138,7 +138,7 @@ sw buf_parse_s_bits$_base (s_buf *buf, const s_str *base,
       goto restore;
     }
     u *= radix;
-    if (negative ? u > (u_bits$) -S_BITS$_MIN - digit :
+    if (negative ? -u < (u_bits$) S_BITS$_MIN + digit :
         u > (u_bits$) (S_BITS$_MAX - digit)) {
       warnx("buf_parse_s_bits$_base: +: integer overflow");
       r = -1;