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

master
indexzero 2011-04-13 18:49:38 -04:00
parent 7484fdb7a0
commit d99ab32cc5
1 changed files with 4 additions and 2 deletions

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);