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 --- include/toml++/impl/preprocessor.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/toml++/impl') diff --git a/include/toml++/impl/preprocessor.hpp b/include/toml++/impl/preprocessor.hpp index ff2ce6dd23..d74d2b616c 100644 --- a/include/toml++/impl/preprocessor.hpp +++ b/include/toml++/impl/preprocessor.hpp @@ -1177,9 +1177,11 @@ #endif #ifndef TOML_MAX_NESTED_VALUES -#define TOML_MAX_NESTED_VALUES 256 +#define TOML_MAX_NESTED_VALUES 128 // this refers to the depth of nested values, e.g. inline tables and arrays. -// 256 is crazy high! if you're hitting this limit with real input, TOML is probably the wrong tool for the job... +// 128 is very generous; real TOML files rarely exceed single-digit nesting. +// keep this value low enough to avoid stack overflows in sanitizer-instrumented builds +// where each recursion cycle may consume ~3KB of stack. #endif #ifndef TOML_MAX_DOTTED_KEYS_DEPTH -- cgit 0.0.5-2-1-g0f52