[backfire] uci: fix segmentation fault in lua api when deleting sections within a...
[openwrt/svn-archive/archive.git] / package / uci / patches / 130-lua_fix_nested_foreach_delete.patch
1 --- a/lua/uci.c
2 +++ b/lua/uci.c
3 @@ -266,7 +266,7 @@ uci_lua_foreach(lua_State *L)
4 {
5 struct uci_context *ctx;
6 struct uci_package *p;
7 - struct uci_element *e;
8 + struct uci_element *e, *tmp;
9 const char *package, *type;
10 bool ret = false;
11 int offset = 0;
12 @@ -287,7 +287,7 @@ uci_lua_foreach(lua_State *L)
13 if (!p)
14 goto done;
15
16 - uci_foreach_element(&p->sections, e) {
17 + uci_foreach_element_safe(&p->sections, tmp, e) {
18 struct uci_section *s = uci_to_section(e);
19
20 i++;