From 9d0396cd638983d207cb7bb0a5a21220a86ec1de Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Sun, 15 Nov 2015 13:56:05 +0900 Subject: [PATCH] util: use Object.create(null) for dictionary object Fixes https://github.com/nodejs/node/issues/3788 `arrayToHash()` needs to use `Object.create(null)` for its dictionary object. Refs: https://github.com/nodejs/node/pull/3791 PR-URL: https://github.com/nodejs/node/pull/3831 Reviewed-By: Trevor Norris Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- lib/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.js b/lib/util.js index 97c5c10fd8..b034b29b55 100644 --- a/lib/util.js +++ b/lib/util.js @@ -159,9 +159,9 @@ function stylizeNoColor(str, styleType) { function arrayToHash(array) { - var hash = {}; + var hash = Object.create(null); - array.forEach(function(val, idx) { + array.forEach(function(val) { hash[val] = true; });