Also validate arguments to MyAvatar.removeAnimationStateHandler() and the return result from the user provided callback function.
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 2 files). Show all
Unified · Split
| @@ -784,7 +784,13 @@ void ScriptEngine::callAnimationStateHandler(QScriptValue callback, AnimVariantM · 783 unmodified lines | |||
| 784 | callingArguments << javascriptParameters; | 784 | callingArguments << javascriptParameters; |
| 785 | assert(currentEntityIdentifier.isInvalidID()); // No animation state handlers from entity scripts. | 785 | assert(currentEntityIdentifier.isInvalidID()); // No animation state handlers from entity scripts. |
| 786 | QScriptValue result = callback.call(QScriptValue(), callingArguments); | 786 | 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 | } | ||
| 788 | } | 794 | } |
| 789 | 795 | ||
| 790 | void ScriptEngine::timerFired() { | 796 | void ScriptEngine::timerFired() { |