Browse Source

Get rid of UB found by UBSan

bessel
Gavin Howard 2 years ago
parent
commit
1f6a8ad9ef
Signed by untrusted user who does not match committer: gavin
GPG Key ID: C08038BDF280D33E
  1. 3
      src/num.c

3
src/num.c

@ -1457,7 +1457,8 @@ static void bc_num_parseDecimal(BcNum *restrict n, const char *restrict val) {
for (i = 0; i < len && (zero = (val[i] == '0' || val[i] == '.')); ++i);
n->scale = (size_t) (rdx * ((val + len) - (ptr + 1)));
n->scale = (size_t) (rdx * (((uintptr_t) (val + len)) -
(((uintptr_t) ptr) + 1)));
n->rdx = BC_NUM_RDX(n->scale);
i = len - (ptr == val ? 0 : i) - rdx;

Loading…
Cancel
Save