From 21ff1e26bbb807bc25303e70bb739cdc6e7ba51f Mon Sep 17 00:00:00 2001 From: cpusci Date: Sun, 4 Aug 2013 08:50:56 -0500 Subject: [PATCH 1/2] If you name a torque script object the same name as a Torque script class, you will get heap corruption with no warning at all. Changed original fix to cause a script error and reject object creation, instead of just renaming the object and moving along. --- Engine/source/console/compiledEval.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index e2cfcf280..6a2c01eac 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -650,6 +650,15 @@ breakContinue: // IF we aren't looking at a local/internal object, then check if // this object already exists in the global space + AbstractClassRep* rep = AbstractClassRep::findClassRep( objectName ); + if (rep != NULL) { + Con::errorf(ConsoleLogEntry::General, "%s: Cannot name object %s the same name as a script class.", + getFileLine(ip), objectName); + ip = failJump; + STR.popFrame(); + break; + } + SimObject *obj = Sim::findObject( objectName ); if (obj /*&& !obj->isLocalName()*/) { From 79c9a21e3258f8668d605a76bcffba994bba1be5 Mon Sep 17 00:00:00 2001 From: cpusci Date: Mon, 5 Aug 2013 06:20:44 -0500 Subject: [PATCH 2/2] Just making sure the error output is consistent with the other errors. --- Engine/source/console/compiledEval.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index 6a2c01eac..37f621997 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -652,7 +652,7 @@ breakContinue: AbstractClassRep* rep = AbstractClassRep::findClassRep( objectName ); if (rep != NULL) { - Con::errorf(ConsoleLogEntry::General, "%s: Cannot name object %s the same name as a script class.", + Con::errorf(ConsoleLogEntry::General, "%s: Cannot name object [%s] the same name as a script class.", getFileLine(ip), objectName); ip = failJump; STR.popFrame();