summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrtt-module.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/rtt-module.js b/rtt-module.js
index 4de3092..a0df345 100755
--- a/rtt-module.js
+++ b/rtt-module.js
@@ -71,8 +71,14 @@ module.exports.fuzz = function(fuzzerInputData) {
let action = data.pickValue(Object.keys(actions))
let args = actions[action]
- // TODO check for NaN as any suggested action argument and raise an error on those
if (args !== undefined && args !== null && typeof args !== "number") {
+ // check for NaN as any suggested action argument and raise an error on those
+ for (const arg in args) {
+ if (isNaN(arg)) {
+ log_crash(game_setup, state, view, step, active)
+ throw new InvalidActionArgument(`Action '${action}' argument has NaN value`)
+ }
+ }
args = data.pickValue(args)
}
@@ -116,6 +122,13 @@ class NoMoreActionsError extends Error {
}
}
+class InvalidActionArgument extends Error {
+ constructor(message) {
+ super(message)
+ this.name = "InvalidActionArgument"
+ }
+}
+
class RulesCrashError extends Error {
constructor(message, stack) {
super(message)