From 96b6dfa83a70f680b3787dd24f87d038e721f11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 8 Nov 2024 13:46:49 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Avoid=20illegal=20memory=20acces?= =?UTF-8?q?s=20when=20variable=20name=20is=20used=20as=20a=20function=20ca?= =?UTF-8?q?ll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call to model_error() would return and lead to an incorrect dereferencing of the optional<int> rv. The call to model_error() should have been replaced by a call to error() in db1f6c2998279582da95b83a1f59cfdf1f8f8c40. Then the move to an optional<int> in 46b2c73565e44bc4bf35ac9d998ed19fb3fd237b introduced the bug. See https://forum.dynare.org/t/preprocessing-failed-for-specific-mod-file/26705 --- src/ParsingDriver.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc index 7f29ae96..7933280a 100644 --- a/src/ParsingDriver.cc +++ b/src/ParsingDriver.cc @@ -3453,10 +3453,9 @@ ParsingDriver::add_model_var_or_external_function(const string& function_name, b optional<int> rv {is_there_one_integer_argument()}; if (!rv) - model_error("Symbol " + function_name - + " is being treated as if it were a function (i.e., takes an argument " - "that is not an integer).", - ""); + error("Symbol " + function_name + + " is being treated as if it were a function (i.e., takes an argument that is " + "not an integer)."); nid = add_model_variable(mod_file->symbol_table.getID(function_name), *rv); stack_external_function_args.pop(); -- GitLab