From f416d2675eb36e3dd2d2b3882058233327ea3c07 Mon Sep 17 00:00:00 2001 From: Johnny Wang Date: Tue, 19 Oct 2021 18:06:49 +0800 Subject: bugfix: fixed bugs suspected by cppcheck: shift signed 32-bit value by 31 bits and uninitialized variable. (#76) [dtoa.c:2453] -> [dtoa.c:2454]: (warning) Shifting signed 32-bit value by 31 bits is undefined behaviour. See condition at line 2453. [dtoa.c:2846]: (error) Uninitialized variable: bb [dtoa.c:2847]: (error) Uninitialized variable: bd [dtoa.c:2848]: (error) Uninitialized variable: bs [dtoa.c:2850]: (error) Uninitialized variable: delta --- dtoa.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dtoa.c b/dtoa.c index 56398ba..4067e5b 100644 --- a/dtoa.c +++ b/dtoa.c @@ -2451,10 +2451,10 @@ retlow1: if ((j = ((word0(rv) & Exp_mask) >> Exp_shift) - bc->scale) <= 0) { i = 1 - j; if (i <= 31) { - if (word1(rv) & (0x1 << i)) + if (word1(rv) & (0x1U << i)) goto odd; } - else if (word0(rv) & (0x1 << (i-32))) + else if (word0(rv) & (0x1U << (i-32))) goto odd; } else if (word1(rv) & 1) { @@ -2488,7 +2488,11 @@ fpconv_strtod U aadj2, adj, rv, rv0; ULong y, z; BCinfo bc; - Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; + Bigint *bb1, *bd0; + Bigint *bb = NULL; + Bigint *bd = NULL; + Bigint *bs = NULL; + Bigint *delta = NULL; #ifdef Avoid_Underflow ULong Lsb, Lsb1; #endif -- cgit v1.2.3-55-g6feb