From d61cb90ee3faeba5c0045f0061fb2349888c8080 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 9a68ea0068cbf3..928e148e28c80b 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; });