From 47fe4b9cee945cdb76c7dae0d5a0c535af2af0cd Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Tue, 15 Jan 2019 20:22:11 +0330 Subject: [PATCH] Add unit test for parsing deeply-nested array --- test/src/unit-regression.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index e739e3c3..b39a9adc 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1708,6 +1708,16 @@ TEST_CASE("regression tests") const auto data = j.get(); CHECK(expected == data); } + + SECTION("issue #1419 - Segmentation fault (stack overflow) due to unbounded recursion") + { + const int depth = 8000000; + + std::string s(depth, '['); + s += std::string(depth, ']'); + + CHECK_NOTHROW(nlohmann::json::parse(s)); + } } TEST_CASE("regression tests, exceptions dependent", "[!throws]")