From 1c8b7466e4946fcc3bf20484c0e1d001202cca5a Mon Sep 17 00:00:00 2001 From: danielbodorin <80352803+danielbodorin@users.noreply.github.com> Date: Mon, 23 Mar 2026 17:33:51 +0200 Subject: fix: lower TOML_MAX_NESTED_VALUES to prevent stack overflow on deeply nested arrays/inline tables (#293) Co-authored-by: Daniel Bodorin --- tests/user_feedback.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/user_feedback.cpp') diff --git a/tests/user_feedback.cpp b/tests/user_feedback.cpp index 6cc1fd34c5..aa1f36b1d6 100644 --- a/tests/user_feedback.cpp +++ b/tests/user_feedback.cpp @@ -168,6 +168,18 @@ b = [] constexpr auto start = "fl =[ "sv; memcpy(s.data(), start.data(), start.length()); parsing_should_fail(FILE_LINE_ARGS, std::string_view{ s }); + + // deeply nested inline tables should also fail gracefully, not stack overflow + { + // build: fl = {a={a={a={a=...{a=1}...}}} + std::string nested_tables = "fl = "; + for (size_t i = 0; i < 2048; i++) + nested_tables += "{a="; + nested_tables += "1"; + for (size_t i = 0; i < 2048; i++) + nested_tables += "}"; + parsing_should_fail(FILE_LINE_ARGS, std::string_view{ nested_tables }); + } } SECTION("tomlplusplus/issues/112") // https://github.com/marzer/tomlplusplus/issues/112 -- cgit 0.0.5-2-1-g0f52