Fixed possible crash in dependency checking

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1113 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-08 23:53:59 +00:00
parent e575af3320
commit d14af1c43a
+6 -1
View File
@@ -67,10 +67,12 @@ class DependencyUnion : public ScriptValue {
// Unify two values from different execution paths
void unify(ScriptValueP& a, const ScriptValueP& b) {
assert(a && b);
if (a != b) a = new_intrusive2<DependencyUnion>(a,b);
}
// Unify two values from different execution paths
ScriptValueP unified(const ScriptValueP& a, const ScriptValueP& b) {
assert(a && b);
if (a == b) return a;
else return new_intrusive2<DependencyUnion>(a,b);
}
@@ -159,7 +161,10 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
}
// unify bindings
FOR_EACH(v, j->bindings) {
setVariable(v.variable, unified(variables[v.variable].value, v.value.value) );
ScriptValueP old_value = variables[v.variable].value;
if (old_value) {
setVariable(v.variable, unified(old_value, v.value.value) );
}
}
delete j;
}