Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
batsim
batsim
Commits
57826cb3
Commit
57826cb3
authored
Apr 15, 2017
by
Millian Poquet
Browse files
[obfh] json writer: safer memory operations
parent
e41ef8c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/protocol.hpp
View file @
57826cb3
...
...
@@ -38,15 +38,16 @@ public:
this
->
Prefix
(
rapidjson
::
kNumberType
);
const
int
buf_size
=
32
;
char
buffer
[
buf_size
];
char
*
buffer
=
new
char
[
buf_size
];
int
ret
=
snprintf
(
buffer
,
size
of
(
buffer
)
,
"%6f"
,
d
);
int
ret
=
snprintf
(
buffer
,
buf_
size
,
"%6f"
,
d
);
RAPIDJSON_ASSERT
(
ret
>=
1
);
const
char
*
end
=
buffer
+
ret
;
RAPIDJSON_ASSERT
(
ret
<
buf_size
-
1
)
;
for
(
char
*
p
=
buffer
;
p
!=
end
;
++
p
)
os_
->
Put
(
*
p
);
for
(
int
i
=
0
;
i
<
ret
;
++
i
)
os_
->
Put
(
buffer
[
i
]
);
delete
[]
buffer
;
return
ret
<
(
buf_size
-
1
);
}
...
...
Write
Preview
Supports
Markdown
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