From 54dc1e2e15c6fc466bd80b8747d1bcc34833b4f4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 24 Sep 2014 11:12:14 -0700 Subject: [PATCH] Exit early from `_.contains` if `length` is `0` to avoid potentially mucking up `getIndexOf` by passing it an `undefined` collection. --- lodash.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lodash.js b/lodash.js index ee9d0cdcd..ff32658d0 100644 --- a/lodash.js +++ b/lodash.js @@ -4712,6 +4712,9 @@ collection = values(collection); length = collection.length; } + if (!length) { + return false; + } if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); } else {