From 54e0bd92c902856fc485611c697236c107ea2344 Mon Sep 17 00:00:00 2001 From: Alexander van Gessel Date: Mon, 23 Jun 2014 17:00:08 +0200 Subject: [PATCH] Prevent infinitely recursive macros (bug #20126) We simply use the system already in place for file inclusions, and bump the limit up to 100 to appease compulsive macro users. --- changelog | 1 + src/serialization/preprocessor.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 8018401c3725..76bd03a46650 100644 --- a/changelog +++ b/changelog @@ -210,6 +210,7 @@ Version 1.13.0-dev: * Fix bug #22134: Campaign prefix not used in mp campaign saves * Made the error messages sent to stderr when the core data dir is incorrectly set more helpful. + * Fix bug #20126: Recursive preprocessor includes cause infinite loop Version 1.11.11: * Add-ons server: diff --git a/src/serialization/preprocessor.cpp b/src/serialization/preprocessor.cpp index 1e36081b1933..9733fcf11dbc 100644 --- a/src/serialization/preprocessor.cpp +++ b/src/serialization/preprocessor.cpp @@ -1053,7 +1053,7 @@ bool preprocessor_data::get_chunk() pop_token(); put(v.str()); } - else if ((macro = target_.defines_->find(symbol)) != target_.defines_->end()) + else if (target_.depth_ < 100 && (macro = target_.defines_->find(symbol)) != target_.defines_->end()) { preproc_define const &val = macro->second; size_t nb_arg = strings_.size() - token.stack_pos - 1;