Skip to content
Snippets Groups Projects
Commit b362e591 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Fixed bug. Uninitialized memory reads because the code was working with a...

Fixed bug. Uninitialized memory reads because the code was working with a std::map, which was volatile.

(cherry picked from commit 7ca36832)
parent 139f5ae7
No related branches found
No related tags found
No related merge requests found
// Copyright (C) 2006-2011, Ondra Kamenik // Copyright (C) 2006-2011, Ondra Kamenik
#include "forw_subst_builder.h" #include "forw_subst_builder.h"
using namespace ogdyn; using namespace ogdyn;
...@@ -47,8 +48,10 @@ void ForwSubstBuilder::substitute_for_term(int t, int i, int j) ...@@ -47,8 +48,10 @@ void ForwSubstBuilder::substitute_for_term(int t, int i, int j)
// first make lagsubst be substitution setting f(x(+4)) to f(x(+1)) // first make lagsubst be substitution setting f(x(+4)) to f(x(+1))
// this is lag = -3 (1-mlead) // this is lag = -3 (1-mlead)
map<int,int> lagsubst; map<int,int> lagsubst;
model.variable_shift_map(model.eqs.nulary_of_term(t), 1-mlead, lagsubst); unordered_set<int> nult = model.eqs.nulary_of_term(t);// make copy of nult!
model.variable_shift_map(nult, 1-mlead, lagsubst);
int lagt = model.eqs.add_substitution(t, lagsubst); int lagt = model.eqs.add_substitution(t, lagsubst);
// now maxlead of lagt is +1 // now maxlead of lagt is +1
// add AUXLD_*_*_1 = f(x(+1)) to the model // add AUXLD_*_*_1 = f(x(+1)) to the model
char name[100]; char name[100];
...@@ -82,7 +85,9 @@ void ForwSubstBuilder::substitute_for_term(int t, int i, int j) ...@@ -82,7 +85,9 @@ void ForwSubstBuilder::substitute_for_term(int t, int i, int j)
aux_map.insert(Tsubstmap::value_type(ss, lagt)); aux_map.insert(Tsubstmap::value_type(ss, lagt));
} }
// now we have to substitute AUXLEAD_*_*{mlead-1}(+1) for t // now we have to substitute AUXLD_*_*{mlead-1}(+1) for t
sprintf(name, "AUXLD_%d_%d_%d", i, j, mlead-1);
ss = model.atoms.get_name_storage().query(name);
model.substitute_atom_for_term(ss, +1, t); model.substitute_atom_for_term(ss, +1, t);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment