Skip to content

Commit 5111798

Browse files
author
Bogdan Degtyariov
committed
Added processing of 64-bit unsigned numbers in the parser
1 parent e1aeb40 commit 5111798

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cdk/parser/json_parser.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,19 @@ bool JSON_scalar_parser::do_parse(It &first, const It &last, Processor *vp)
107107
{
108108
if(vp)
109109
{
110-
int64_t val = boost::lexical_cast<int64_t>(first->get_text());
111-
vp->num(neg ? -val : val);
110+
uint64_t val = boost::lexical_cast<uint64_t>(first->get_text());
111+
if (val > (uint64_t)std::numeric_limits<int64_t>::max())
112+
{
113+
if (neg)
114+
throw Error("The value is too large for a signed type");
115+
// Unsigned type is only returned for large values
116+
vp->num(val);
117+
}
118+
else
119+
{
120+
// All values MOD(val) < LLONG_MAX are signed
121+
vp->num(neg ? -(int64_t)val : (int64_t)val);
122+
}
112123
}
113124
++first;
114125
return true;

0 commit comments

Comments
 (0)