From 4f4b029538b6dc8a317f0f3a684379dabb351ae7 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 4 Feb 2024 12:50:02 +0100 Subject: [PATCH] RapidJSON: use iterative parsing instead Use iterative parsing to protect against stack overflows in rare cases --- r5dev/cmake/Options.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/r5dev/cmake/Options.cmake b/r5dev/cmake/Options.cmake index 56779770..a5972304 100644 --- a/r5dev/cmake/Options.cmake +++ b/r5dev/cmake/Options.cmake @@ -25,8 +25,8 @@ macro( apply_project_settings ) set( OPTION_LTCG_MODE "OFF" CACHE STRING "Enables link-time code generation (significantly increases compile times)" ) set_property( CACHE OPTION_LTCG_MODE PROPERTY STRINGS "OFF" - "ON" - "ALL" + "ON" # Only on projects that specified LTCG + "ALL" # All projects, whether or not LTCG was specified ) option( OPTION_CERTAIN "This build is certain; debug statements (such as DevMsg(...)) will NOT be compiled" OFF ) @@ -44,6 +44,12 @@ macro( apply_project_settings ) # SSE3 and higher, and the next level of optimizations in RapidJSON is SSE4.2. "RAPIDJSON_SSE2" + # Use iterative parsing to protect against stack overflows in rare cases; see: + # https://rapidjson.org/md_doc_features.html + # https://github.com/Tencent/rapidjson/issues/1227 + # https://github.com/Tencent/rapidjson/issues/2260 + "RAPIDJSON_PARSE_DEFAULT_FLAGS=kParseIterativeFlag" + # Target is 64bits only. "PLATFORM_64BITS" )