From 112ec73c95a076e922982d75a8929031e5dc6f51 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Aug 2019 19:42:35 -0700 Subject: [PATCH] util: isEqualBoxedPrimitive: ensure both values are actual boxed Symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... before trying to valueOf them PR-URL: https://github.com/nodejs/node/pull/29029 Reviewed-By: James M Snell Reviewed-By: Gus Caplan Reviewed-By: Michaƫl Zasso Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- lib/internal/util/comparisons.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 777ae07aed85a4..a895da2ad12945 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -98,8 +98,11 @@ function isEqualBoxedPrimitive(val1, val2) { return isBigIntObject(val2) && BigIntPrototype.valueOf(val1) === BigIntPrototype.valueOf(val2); } - return isSymbolObject(val2) && - SymbolPrototype.valueOf(val1) === SymbolPrototype.valueOf(val2); + if (isSymbolObject(val1)) { + return isSymbolObject(val2) && + SymbolPrototype.valueOf(val1) === SymbolPrototype.valueOf(val2); + } + return false; } // Notes: Type tags are historical [[Class]] properties that can be set by