From 44444161757955688827e829ff48b3ff3f0ff9a8 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 18 May 2023 14:58:44 +0000 Subject: [PATCH] handle NaN or undefined values in approveResources Signed-off-by: Arthur Lu --- utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils.js b/utils.js index 55df6d2..700fdbe 100644 --- a/utils.js +++ b/utils.js @@ -21,9 +21,12 @@ export async function approveResources(req, username, request) { if (!(key in avail)) { approved = false; } - else if (avail[key] - request[key] < 0) { + else if (isNaN(avail[key]) || isNaN(request[key])) { approved = false; } + else if (avail[key] - request[key] < 0) { + approved = false; + } }); return approved; } \ No newline at end of file