Skip to content

Commit c511ce3

Browse files
authored
Merge pull request Tencent#1250 from StilesCrisis/issue-1249-test
Unit Test: Parsing "0e100" in full precision mode causes UB
2 parents 6cc3910 + cad3805 commit c511ce3

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

include/rapidjson/internal/diyfp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ struct DiyFp {
100100
}
101101

102102
DiyFp Normalize() const {
103+
RAPIDJSON_ASSERT(f != 0); // https://stackoverflow.com/a/26809183/291737
103104
#if defined(_MSC_VER) && defined(_M_AMD64)
104105
unsigned long index;
105106
_BitScanReverse64(&index, f);

test/unittest/readertest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ static void TestParseDouble() {
207207

208208
TEST_DOUBLE(fullPrecision, "0.0", 0.0);
209209
TEST_DOUBLE(fullPrecision, "-0.0", -0.0); // For checking issue #289
210+
TEST_DOUBLE(fullPrecision, "0e100", 0.0); // For checking issue #1249
210211
TEST_DOUBLE(fullPrecision, "1.0", 1.0);
211212
TEST_DOUBLE(fullPrecision, "-1.0", -1.0);
212213
TEST_DOUBLE(fullPrecision, "1.5", 1.5);

0 commit comments

Comments
 (0)