summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-olsr
diff options
context:
space:
mode:
authorLars Kruse <lists@sumpfralle.de>2018-04-07 18:05:51 +0200
committerLars Kruse <lists@sumpfralle.de>2019-08-02 22:31:03 +0200
commit7863ff72724bbb84831d595ef60405072713c379 (patch)
treea3b10859cebf177933e247215f9c9b08afe5f309 /applications/luci-app-olsr
parent07dbee37f858b93c10fe5114fbe55e36ddb0d654 (diff)
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>
Diffstat (limited to 'applications/luci-app-olsr')
-rw-r--r--applications/luci-app-olsr/luasrc/controller/olsr.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/applications/luci-app-olsr/luasrc/controller/olsr.lua b/applications/luci-app-olsr/luasrc/controller/olsr.lua
index 11e27d7c00..75463d405c 100644
--- a/applications/luci-app-olsr/luasrc/controller/olsr.lua
+++ b/applications/luci-app-olsr/luasrc/controller/olsr.lua
@@ -379,9 +379,9 @@ function fetch_jsoninfo(otable)
if jsonreq4 ~= "" then
has_v4 = 1
- jsondata4 = json.decode(jsonreq4)
+ jsondata4 = json.decode(jsonreq4) or {}
if otable == 'status' then
- data4 = jsondata4 or {}
+ data4 = jsondata4
else
data4 = jsondata4[otable] or {}
end
@@ -393,9 +393,9 @@ function fetch_jsoninfo(otable)
end
if jsonreq6 ~= "" then
has_v6 = 1
- jsondata6 = json.decode(jsonreq6)
+ jsondata6 = json.decode(jsonreq6) or {}
if otable == 'status' then
- data6 = jsondata6 or {}
+ data6 = jsondata6
else
data6 = jsondata6[otable] or {}
end