avoid array index out-of-bounds
UBSAN gave "runtime error: index 13 out of bounds for type 'const uint32_t [10]'"
This commit is contained in:
parent
5c77c9248c
commit
fe550f3866
@ -102,7 +102,8 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff
|
||||
kappa--;
|
||||
if (p2 < delta) {
|
||||
*K += kappa;
|
||||
GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * kPow10[-static_cast<int>(kappa)]);
|
||||
int index = -static_cast<int>(kappa);
|
||||
GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * (index < 9 ? kPow10[-static_cast<int>(kappa)] : 0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ TEST(dtoa, normal) {
|
||||
TEST_DTOA(1.2345678, "1.2345678");
|
||||
TEST_DTOA(0.123456789012, "0.123456789012");
|
||||
TEST_DTOA(1234567.8, "1234567.8");
|
||||
TEST_DTOA(-79.39773355813419, "-79.39773355813419");
|
||||
TEST_DTOA(0.000001, "0.000001");
|
||||
TEST_DTOA(0.0000001, "1e-7");
|
||||
TEST_DTOA(1e30, "1e30");
|
||||
|
Loading…
x
Reference in New Issue
Block a user