diff options
author | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-08-25 14:17:10 +0200 |
---|---|---|
committer | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-08-25 14:17:10 +0200 |
commit | 5415edecf40714f2fef25a0b3511bc5ed2a0bd3a (patch) | |
tree | 7210df92b172883901bd9864d8c319ee1eee559b | |
parent | db379e8794497f6f7ac88b817d0a2473c4e99d9a (diff) | |
download | fuzzer-5415edecf40714f2fef25a0b3511bc5ed2a0bd3a.tar.gz |
raise error on NaN value
-rwxr-xr-x | rtt-module.js | 15 |
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) |