Commit e9ae9a1d authored by Igor Sugak's avatar Igor Sugak Committed by facebook-github-bot-0

folly/test/json_test: fix heap-buffer-overflow in Json.PrintTo test

Summary:Json.PrintTo test if failing with heap-buffer-overflow asan abort. The problem here comes up
when values of `std::string` and `std::ostrstring::str()` are compared.  `std::ostrstring::str()` returns
*non null* terminated array of `char`s. When compared with `std::string` a read from memory after
the end that array is made. Fixing the test by replacing `std::ostrstream` with `std::ostringstream`,
that does append `\0`.

Reviewed By: yfeldblum

Differential Revision: D2934352

fb-gh-sync-id: c6a5d765c9951716b8a14715702cf3d940c6d723
shipit-source-id: c6a5d765c9951716b8a14715702cf3d940c6d723
parent f79de567
...@@ -466,7 +466,7 @@ TEST(Json, SortKeys) { ...@@ -466,7 +466,7 @@ TEST(Json, SortKeys) {
} }
TEST(Json, PrintTo) { TEST(Json, PrintTo) {
std::ostrstream oss; std::ostringstream oss;
dynamic value = dynamic::object dynamic value = dynamic::object
("foo", "bar") ("foo", "bar")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment