Skip to content

Commit 5328383

Browse files
committed
intentional bug
1 parent 344bd31 commit 5328383

File tree

1 file changed

+13
-56
lines changed

1 file changed

+13
-56
lines changed

include/boost/json/basic_parser_impl.hpp

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,66 +2633,23 @@ parse_number(const char* p,
26332633
num_buf_.append( begin, cs.used(begin) );
26342634
return suspend(cs.begin(), state::exp3, num);
26352635
}
2636+
goto finish_dub;
26362637
}
2637-
else
2638-
{
2639-
char const c = *cs;
2640-
if(BOOST_JSON_LIKELY( c >= '0' && c <= '9' ))
2641-
{
2642-
if(BOOST_JSON_UNLIKELY(
2643-
// 2147483647 INT_MAX
2644-
num.exp > 214748364 ||
2645-
(num.exp == 214748364 && c > '7')
2646-
))
2647-
num.exp = INT_MAX;
2648-
else BOOST_IF_CONSTEXPR( !no_parsing )
2649-
num.exp = 10 * num.exp + ( c - '0' );
2650-
2651-
++cs;
2652-
continue;
2653-
}
2654-
}
2655-
BOOST_ASSERT(num.exp >= 0);
2656-
if ( num.frac )
2657-
{
2658-
if(BOOST_JSON_UNLIKELY( num.bias < (INT_MIN + num.exp) ))
2659-
{
2660-
// if exponent overflowed, bias is a very large negative
2661-
// number, and mantissa isn't zero, then we cannot parse the
2662-
// number correctly
2663-
if(BOOST_JSON_UNLIKELY(
2664-
(num.exp == INT_MAX) &&
2665-
(num.bias < 0) &&
2666-
(num.exp + num.bias < 308) &&
2667-
num.mant ))
2668-
{
2669-
BOOST_STATIC_CONSTEXPR source_location loc
2670-
= BOOST_CURRENT_LOCATION;
2671-
return fail(cs.begin(), error::exponent_overflow, &loc);
2672-
}
2673-
2674-
num.bias = 0;
2675-
num.exp = INT_MAX;
2676-
}
2677-
}
2678-
else if (BOOST_JSON_UNLIKELY( num.bias > (INT_MAX - num.exp) ))
2638+
char const c = *cs;
2639+
if(BOOST_JSON_LIKELY(
2640+
c >= '0' && c <= '9'))
26792641
{
2680-
// if exponent overflowed, bias is a very large positive number,
2681-
// and mantissa isn't zero, then we cannot parse the
2682-
// number correctly
26832642
if(BOOST_JSON_UNLIKELY(
2684-
(num.exp == INT_MAX) &&
2685-
(num.bias > 0) &&
2686-
(num.exp - num.bias < 308) &&
2687-
num.mant ))
2688-
{
2689-
BOOST_STATIC_CONSTEXPR source_location loc
2690-
= BOOST_CURRENT_LOCATION;
2691-
return fail(cs.begin(), error::exponent_overflow, &loc);
2692-
}
2643+
// 2147483647 INT_MAX
2644+
num.exp > 214748364 ||
2645+
(num.exp == 214748364 && c > '7')
2646+
))
2647+
num.exp = INT_MAX;
2648+
else BOOST_IF_CONSTEXPR( !no_parsing )
2649+
num.exp = 10 * num.exp + ( c - '0' );
26932650

2694-
num.bias = 0;
2695-
num.exp = INT_MAX;
2651+
++cs;
2652+
continue;
26962653
}
26972654
goto finish_dub;
26982655
}

0 commit comments

Comments
 (0)