From 5415edecf40714f2fef25a0b3511bc5ed2a0bd3a Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Fri, 25 Aug 2023 14:17:10 +0200 Subject: raise error on NaN value --- rtt-module.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3