Fixes accesses to possibly nil discovered data

This commit is contained in:
Simone Mainardi 2019-11-19 18:12:56 +01:00
parent b7f383e656
commit d3995e36a2
2 changed files with 13 additions and 9 deletions

View file

@ -1130,6 +1130,10 @@ local function discovery2config(interface_name)
local cached = ntop.getCache(getCachedDiscoveryKey(interface_name))
local disc = json.decode(cached)
if isEmptyString(cached) or not disc then
return
end
disc["devices"] = ntop.lrangeCache(getCachedDiscoveredDevicesKey(interface_name), 0, -1) or {}
for i=1, #disc["devices"] do
disc["devices"][i] = json.decode(disc["devices"][i])