Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
b9f31494
Unverified
Commit
b9f31494
authored
Feb 15, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚑
fix for #452
parent
82fb6137
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
1 deletion
+17
-1
json.hpp
src/json.hpp
+0
-0
json.hpp.re2c
src/json.hpp.re2c
+2
-0
unit-class_parser.cpp
test/src/unit-class_parser.cpp
+3
-1
unit-regression.cpp
test/src/unit-regression.cpp
+12
-0
No files found.
src/json.hpp
View file @
b9f31494
This diff is collapsed.
Click to expand it.
src/json.hpp.re2c
View file @
b9f31494
...
@@ -9698,6 +9698,8 @@ class basic_json
...
@@ -9698,6 +9698,8 @@ class basic_json
exp = e (minus | plus)? digit+;
exp = e (minus | plus)? digit+;
frac = decimal_point digit+;
frac = decimal_point digit+;
int = (zero | digit_1_9 digit*);
int = (zero | digit_1_9 digit*);
invalid_int = minus? "0" digit+;
invalid_int { last_token_type = token_type::parse_error; break; }
number_unsigned = int;
number_unsigned = int;
number_unsigned { last_token_type = token_type::value_unsigned; break; }
number_unsigned { last_token_type = token_type::value_unsigned; break; }
number_integer = minus int;
number_integer = minus int;
...
...
test/src/unit-class_parser.cpp
View file @
b9f31494
...
@@ -299,7 +299,9 @@ TEST_CASE("parser class")
...
@@ -299,7 +299,9 @@ TEST_CASE("parser class")
CHECK_THROWS_AS
(
json
::
parser
(
"+0"
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_AS
(
json
::
parser
(
"+0"
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
json
::
parser
(
"01"
).
parse
(),
CHECK_THROWS_WITH
(
json
::
parser
(
"01"
).
parse
(),
"parse error - unexpected number literal"
);
"parse error - unexpected '01'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
"-01"
).
parse
(),
"parse error - unexpected '-01'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
"--1"
).
parse
(),
"parse error - unexpected '-'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
"--1"
).
parse
(),
"parse error - unexpected '-'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
"1."
).
parse
(),
CHECK_THROWS_WITH
(
json
::
parser
(
"1."
).
parse
(),
"parse error - unexpected '.'; expected end of input"
);
"parse error - unexpected '.'; expected end of input"
);
...
...
test/src/unit-regression.cpp
View file @
b9f31494
...
@@ -724,4 +724,16 @@ TEST_CASE("regression tests")
...
@@ -724,4 +724,16 @@ TEST_CASE("regression tests")
};
};
CHECK_THROWS_AS
(
json
::
from_cbor
(
vec2
),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
::
from_cbor
(
vec2
),
std
::
out_of_range
);
}
}
SECTION
(
"issue #452 - Heap-buffer-overflow (OSS-Fuzz issue 585)"
)
{
std
::
vector
<
uint8_t
>
vec
=
{
'-'
,
'0'
,
'1'
,
'2'
,
'2'
,
'7'
,
'4'
};
CHECK_THROWS_AS
(
json
::
parse
(
vec
),
std
::
invalid_argument
);
}
//SECTION("issue #454 - doubles are printed as integers")
//{
// json j = R"({"bool_value":true,"double_value":2.0,"int_value":10,"level1":{"list_value":[3,"hi",false],"tmp":5.0},"string_value":"hello"})"_json;
// CHECK(j["double_value"].is_number_integer());
//}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment