From 42151228240c5c818ac5327d6ff5c01398805564 Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Tue, 11 Aug 2020 06:04:08 +0530 Subject: [PATCH] fix: while validating for offset, check for offset's value for NaN instead length (#2124) --- packages/binding-abstract/lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/binding-abstract/lib/index.js b/packages/binding-abstract/lib/index.js index 3112f1cae..1c89713a8 100644 --- a/packages/binding-abstract/lib/index.js +++ b/packages/binding-abstract/lib/index.js @@ -85,8 +85,8 @@ The in progress reads must error when the port is closed with an error object th throw new TypeError('"buffer" is not a Buffer') } - if (typeof offset !== 'number' || isNaN(length)) { - throw new TypeError(`"offset" is not an integer got "${isNaN(length) ? 'NaN' : typeof offset}"`) + if (typeof offset !== 'number' || isNaN(offset)) { + throw new TypeError(`"offset" is not an integer got "${isNaN(offset) ? 'NaN' : typeof offset}"`) } if (typeof length !== 'number' || isNaN(length)) {