diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-11-05 18:47:34 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-11-05 18:53:09 +0100 |
commit | aaf9dff96d391f1d3fdc73dc5eb14b0d6b51085d (patch) | |
tree | 86e318d9a6fcd219c50c51b39fd4388fa0338550 | |
parent | 2cd94fd505b293e657278e31deb32a7d66d20714 (diff) | |
download | uci-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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); |