folly/test/json_test: fix heap-buffer-overflow in Json.PrintTo test
authorIgor Sugak <sugak@fb.com>
Fri, 12 Feb 2016 23:54:28 +0000 (15:54 -0800)
committerfacebook-github-bot-0 <folly-bot@fb.com>
Sat, 13 Feb 2016 00:20:26 +0000 (16:20 -0800)
commite9ae9a1d8d7419d99a97050112231c9cd18cf9d8
treeefd128a9e96fbf99c1a5c38685500e95c6583934
parentf79de56743edf4a073b480841f1e086df56b1c77
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
folly/test/JsonTest.cpp