From f05a4784fd7eca02cf0e44a59da45ff5c08d0555 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Tue, 10 Dec 2013 13:55:35 +0400 Subject: [PATCH] fixing crash on bad tags --- lib/local-storage.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/local-storage.js b/lib/local-storage.js index 08b5955cb..764feafd1 100644 --- a/lib/local-storage.js +++ b/lib/local-storage.js @@ -151,10 +151,17 @@ Storage.prototype.update_versions = function(name, newdata, callback) { } } for (var tag in newdata['dist-tags']) { - // if tag is updated to reference latter version, that's fine - var need_change = - (data['dist-tags'][tag] == null) || - (!semver.gte(newdata['dist-tags'][tag], data['dist-tags'][tag])) + if (!Array.isArray(data['dist-tags'][tag]) || data['dist-tags'][tag].length != newdata['dist-tags'][tag].length) { + // backward compat + var need_change = true + } else { + for (var i=0; i