summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-11-05 18:47:34 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-11-05 18:53:09 +0100
commitaaf9dff96d391f1d3fdc73dc5eb14b0d6b51085d (patch)
tree86e318d9a6fcd219c50c51b39fd4388fa0338550
parent2cd94fd505b293e657278e31deb32a7d66d20714 (diff)
downloaduci-aaf9dff96d391f1d3fdc73dc5eb14b0d6b51085d.tar.gz
lua: fix invocation of foreach() with nil type and implicit self
The check for nil on the 2nd argument misses the offset in order to skip over implicit self which results in `bad argument #2 to 'foreach' (string expected, got nil)` when invoking `uci.cursor():foreach("test", nil, function(s) end)`. The same call works fine when using dot instead of colon notation. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
-rw-r--r--lua/uci.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lua/uci.c b/lua/uci.c
index 6ba7da0..1cb31a5 100644
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -303,7 +303,7 @@ uci_lua_foreach(lua_State *L)
ctx = find_context(L, &offset);
package = luaL_checkstring(L, 1 + offset);
- if (lua_isnil(L, 2))
+ if (lua_isnil(L, 2 + offset))
type = NULL;
else
type = luaL_checkstring(L, 2 + offset);