History

validate arguments to MyAvatar.addAnimationStateHandler()

Also validate arguments to MyAvatar.removeAnimationStateHandler() and the return result from the user provided callback function.

Anthony J. Thibault committed 10 years ago

Commit 253e4cb1 parent ea4da052 files · +50 −14Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 2 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+7−1
@@ -784,7 +784,13 @@ void ScriptEngine::callAnimationStateHandler(QScriptValue callback, AnimVariantM · 783 unmodified lines
784784 callingArguments << javascriptParameters;
785785 assert(currentEntityIdentifier.isInvalidID()); // No animation state handlers from entity scripts.
786786 QScriptValue result = callback.call(QScriptValue(), callingArguments);
787− resultHandler(result);
787+
788+ // validate result from callback function.
789+ if (result.isValid() && result.isObject()) {
790+ resultHandler(result);
791+ } else {
792+ qCWarning(scriptengine) << "ScriptEngine::callAnimationStateHandler invalid return argument from callback, expected an object";
793+ }
788794 }
789795
790796 void ScriptEngine::timerFired() {