luci-app-olsr: handle empty result for non-status tables
The response of the jsoninfo request may be non-empty (e.g. a linebreak or just whitespace), but still yield "nil" after "json.decode". This situation was already handled for the "status" request, but it leads to a dictionary access against a "nil" value for all other tables. Signed-off-by: Lars Kruse <lists@sumpfralle.de>
This commit is contained in:
parent
07dbee37f8
commit
7863ff7272
1 changed files with 4 additions and 4 deletions
|
@ -379,9 +379,9 @@ function fetch_jsoninfo(otable)
|
||||||
|
|
||||||
if jsonreq4 ~= "" then
|
if jsonreq4 ~= "" then
|
||||||
has_v4 = 1
|
has_v4 = 1
|
||||||
jsondata4 = json.decode(jsonreq4)
|
jsondata4 = json.decode(jsonreq4) or {}
|
||||||
if otable == 'status' then
|
if otable == 'status' then
|
||||||
data4 = jsondata4 or {}
|
data4 = jsondata4
|
||||||
else
|
else
|
||||||
data4 = jsondata4[otable] or {}
|
data4 = jsondata4[otable] or {}
|
||||||
end
|
end
|
||||||
|
@ -393,9 +393,9 @@ function fetch_jsoninfo(otable)
|
||||||
end
|
end
|
||||||
if jsonreq6 ~= "" then
|
if jsonreq6 ~= "" then
|
||||||
has_v6 = 1
|
has_v6 = 1
|
||||||
jsondata6 = json.decode(jsonreq6)
|
jsondata6 = json.decode(jsonreq6) or {}
|
||||||
if otable == 'status' then
|
if otable == 'status' then
|
||||||
data6 = jsondata6 or {}
|
data6 = jsondata6
|
||||||
else
|
else
|
||||||
data6 = jsondata6[otable] or {}
|
data6 = jsondata6[otable] or {}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue