[fix] Dont allow async.forEach to be called on undefined or null arrays

This commit is contained in:
indexzero 2011-04-13 18:49:38 -04:00
parent 7484fdb7a0
commit d99ab32cc5

View file

@ -280,7 +280,7 @@ Redis.prototype.load = function (callback) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
function addValue (key, next) { function addValue (key, next) {
self.get(key, function (err, value) { self.get(key, function (err, value) {
if (err) { if (err) {
@ -292,6 +292,7 @@ Redis.prototype.load = function (callback) {
}); });
} }
keys = keys || [];
async.forEach(keys, addValue, function (err) { async.forEach(keys, addValue, function (err) {
return err ? callback(err) : callback(null, result); return err ? callback(err) : callback(null, result);
}); });
@ -316,7 +317,8 @@ Redis.prototype.reset = function (callback) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
existing = existing || [];
async.forEach(existing, function (key, next) { async.forEach(existing, function (key, next) {
self.clear(key, next); self.clear(key, next);
}, callback); }, callback);