From d14af1c43ac64d65e2be4be2d162ef35ab2421fc Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 8 Aug 2008 23:53:59 +0000 Subject: [PATCH] Fixed possible crash in dependency checking git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1113 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/script/dependency.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/script/dependency.cpp b/src/script/dependency.cpp index 9fceb8f6..5afcc628 100644 --- a/src/script/dependency.cpp +++ b/src/script/dependency.cpp @@ -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(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(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; }