From a5a69f126058f1ac78de546a5c0f86e2cb599534 Mon Sep 17 00:00:00 2001 From: herbetom <git@herbetom.de> Date: Wed, 27 May 2020 00:48:59 +0200 Subject: [PATCH] app: fix potential null reference Without the if it was possible that images[vendor] was undefined because their was no image available for that vendor. And then `Object.entries(images[vendor])` resulted in: Uncaught TypeError: Cannot convert undefined or null to object And this led to the problem that no device at all was shown :( Fixes d45019d10 ("app: filter vendors without images for enabled device categories") Fixes #118 Closes #122 --- app.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 6c2eb6e..a6f160d 100644 --- a/app.js +++ b/app.js @@ -727,9 +727,11 @@ var firmwarewizard = function() { function hasVendorDevicesForEnabledDeviceCategories(vendor) { var image_vendors = Object.keys(images); - for (let [key, value] of Object.entries(images[vendor])) { - if (enabled_device_categories.includes(value[0].category)) { - return true; + if (images[vendor]) { + for (let [key, value] of Object.entries(images[vendor])) { + if (enabled_device_categories.includes(value[0].category)) { + return true; + } } } return false; -- GitLab