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