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
d6085116
Unverified
Commit
d6085116
authored
Mar 22, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚨
fixed a compiler warning #527
The result of snprintf is later used in situations where a long may overflow.
parent
67a06834
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
json.hpp
src/json.hpp
+5
-6
json.hpp.re2c
src/json.hpp.re2c
+5
-6
No files found.
src/json.hpp
View file @
d6085116
...
...
@@ -6929,8 +6929,8 @@ class basic_json
static
constexpr
auto
d
=
std
::
numeric_limits
<
number_float_t
>::
digits10
;
// the actual conversion
long
len
=
snprintf
(
number_buffer
.
data
(),
number_buffer
.
size
(),
"%.*g"
,
d
,
x
);
std
::
ptrdiff_t
len
=
snprintf
(
number_buffer
.
data
(),
number_buffer
.
size
(),
"%.*g"
,
d
,
x
);
// negative value indicates an error
assert
(
len
>
0
);
...
...
@@ -10429,10 +10429,9 @@ class basic_json
Proof (by contradiction): Assume a finite input. To loop forever, the
loop must never hit code with a `break` statement. The only code
snippets without a `break` statement are the continue statements for
whitespace and byte-order-marks. To loop forever, the input must be an
infinite sequence of whitespace or byte-order-marks. This contradicts
the assumption of finite input, q.e.d.
snippets without a `break` statement is the continue statement for
whitespace. To loop forever, the input must be an infinite sequence
whitespace. This contradicts the assumption of finite input, q.e.d.
*/
token_type
scan
()
{
...
...
src/json.hpp.re2c
View file @
d6085116
...
...
@@ -6929,8 +6929,8 @@ class basic_json
static constexpr auto d = std::numeric_limits<number_float_t>::digits10;
// the actual conversion
long
len = snprintf(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
std::ptrdiff_t
len = snprintf(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
// negative value indicates an error
assert(len > 0);
...
...
@@ -10429,10 +10429,9 @@ class basic_json
Proof (by contradiction): Assume a finite input. To loop forever, the
loop must never hit code with a `break` statement. The only code
snippets without a `break` statement are the continue statements for
whitespace and byte-order-marks. To loop forever, the input must be an
infinite sequence of whitespace or byte-order-marks. This contradicts
the assumption of finite input, q.e.d.
snippets without a `break` statement is the continue statement for
whitespace. To loop forever, the input must be an infinite sequence
whitespace. This contradicts the assumption of finite input, q.e.d.
*/
token_type scan()
{
...
...
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