summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-08-25 14:17:10 +0200
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-08-25 14:17:10 +0200
commit5415edecf40714f2fef25a0b3511bc5ed2a0bd3a (patch)
tree7210df92b172883901bd9864d8c319ee1eee559b
parentdb379e8794497f6f7ac88b817d0a2473c4e99d9a (diff)
downloadfuzzer-5415edecf40714f2fef25a0b3511bc5ed2a0bd3a.tar.gz
raise error on NaN value
-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)