From ac793e957ff7efdd37f198f86feaea02051692e7 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 12 Jun 2017 18:58:58 +0200 Subject: [PATCH 1/3] :hammer: trying to fix #367 Code from https://stackoverflow.com/a/44503794/266378 which is hopefully working with MSVC. --- src/json.hpp | 3 ++- test/src/unit-regression.cpp | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 2dd55104a..9af2a98d0 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -8862,7 +8862,8 @@ class basic_json // We initially read a lot of characters into the buffer, and we // may not have processed all of them. Therefore, we need to // "rewind" the stream after the last processed char. - is.seekg(start_position + static_cast(processed_chars)); + is.seekg(start_position); + is.ignore(processed_chars); // clear stream flags is.clear(); } diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index ec8ba6ad6..f4f1f61da 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -711,7 +711,6 @@ TEST_CASE("regression tests") "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input"); } - /* SECTION("second example from #529") { std::string str = "{\n\"one\" : 1,\n\"two\" : 2\n}\n{\n\"three\" : 3\n}"; @@ -749,7 +748,6 @@ TEST_CASE("regression tests") std::remove("test.json"); } - */ } SECTION("issue #389 - Integer-overflow (OSS-Fuzz issue 267)") From afb959a083d41b715ecdbc46295d32a3850ec7a2 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 12 Jun 2017 19:02:08 +0200 Subject: [PATCH 2/3] :hammer: removed nonportable code --- test/src/unit-regression.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index f4f1f61da..cd2374ff8 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -734,13 +734,11 @@ TEST_CASE("regression tests") if (i == 0) { CHECK(val == json({{"one", 1}, {"two", 2}})); - CHECK(static_cast(stream.tellg()) == 28); } if (i == 1) { CHECK(val == json({{"three", 3}})); - CHECK(static_cast(stream.tellg()) == 44); } ++i; From 88dc7c11fa6ba93b33133e1d5bfc13499cb83eac Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 12 Jun 2017 19:58:44 +0200 Subject: [PATCH 3/3] :hammer: fixed a warning --- src/json.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/json.hpp b/src/json.hpp index 9af2a98d0..eb4df22f6 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -8863,7 +8863,7 @@ class basic_json // may not have processed all of them. Therefore, we need to // "rewind" the stream after the last processed char. is.seekg(start_position); - is.ignore(processed_chars); + is.ignore(static_cast(processed_chars)); // clear stream flags is.clear(); }