From 37c2a528336b41b31abe4826b308071896e42423 Mon Sep 17 00:00:00 2001 From: "Lucio M. Tato" Date: Sat, 2 Aug 2014 02:33:35 -0300 Subject: [PATCH] path: fix slice OOB in trim Internal function trim(arr). 2nd parameter of slice() should be slice's end index (not included). Because of function normalize() (called before trim()), "start" is always zero so the bug -for now- has no effect, but its a bug waiting to happen. Reviewed-by: Trevor Norris --- lib/path.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/path.js b/lib/path.js index 768c4c1e5bc857..04187aaf2f4a45 100644 --- a/lib/path.js +++ b/lib/path.js @@ -269,7 +269,7 @@ if (isWindows) { } if (start > end) return []; - return arr.slice(start, end - start + 1); + return arr.slice(start, end + 1); } var toParts = trim(to.split('\\')); @@ -413,7 +413,7 @@ if (isWindows) { } if (start > end) return []; - return arr.slice(start, end - start + 1); + return arr.slice(start, end + 1); } var fromParts = trim(from.split('/'));