summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-10-26 03:04:41 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-10-26 03:04:41 +0000
commit334756a472e933c4fe407aaa9df66d56ccd3e94a (patch)
treeb90c596d523305c31835dd4b5029b8617bbceaeb
parentd409dd68fff8e51a697af91beb26a027ef780355 (diff)
libs/web: fix possible dispatcher crash
-rw-r--r--libs/web/luasrc/dispatcher.lua27
1 files changed, 15 insertions, 12 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index b1ed62b82..fa78b2f65 100644
--- a/libs/web/luasrc/dispatcher.lua
+++ b/libs/web/luasrc/dispatcher.lua
@@ -92,18 +92,21 @@ end
-- @param node Dispatch node
-- @return Ordered table of child node names
function node_childs(node)
- local rv = { }
- local k, v
- for k, v in util.spairs(node.nodes,
- function(a, b)
- return (node.nodes[a].order or 100) < (node.nodes[b].order or 100)
- end)
- do
- if node_visible(v) then
- rv[#rv+1] = k
- end
- end
- return rv
+ local rv = { }
+ if node then
+ local k, v
+ for k, v in util.spairs(node.nodes,
+ function(a, b)
+ return (node.nodes[a].order or 100)
+ < (node.nodes[b].order or 100)
+ end)
+ do
+ if node_visible(v) then
+ rv[#rv+1] = k
+ end
+ end
+ end
+ return rv
end