node-triton#94 Protect against cache lookup returning null
If the cache file does not exist _cacheGetJson will not pass any value to the callback. In the getImage function the callback passed to _cacheGetJson assumes if there was no error value then the second argument must be an array. Add some logic to guard against null values before iterating over the array.
This commit is contained in:
parent
314a05b082
commit
bcf55f0a63
@ -354,12 +354,14 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
|
||||
next(err);
|
||||
return;
|
||||
}
|
||||
if (images) {
|
||||
for (var i = 0; i < images.length; i++) {
|
||||
if (images[i].id === opts.name) {
|
||||
img = images[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
Reference in New Issue
Block a user