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,10 +354,12 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
|
|||||||
next(err);
|
next(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (var i = 0; i < images.length; i++) {
|
if (images) {
|
||||||
if (images[i].id === opts.name) {
|
for (var i = 0; i < images.length; i++) {
|
||||||
img = images[i];
|
if (images[i].id === opts.name) {
|
||||||
break;
|
img = images[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
|
Reference in New Issue
Block a user