case 4:
/* Format: uci.set("p", "s", "o", "v") */
if (lua_istable(L, nargs)) {
- if (lua_rawlen(L, nargs) < 1)
+ if (lua_rawlen(L, nargs) < 1) {
+ free(s);
return luaL_error(L, "Cannot set an uci option to an empty table value");
+ }
lua_rawgeti(L, nargs, 1);
ptr.value = luaL_checkstring(L, -1);
lua_pop(L, 1);
lua_newtable(L);
if (package) {
uci_lua_changes_pkg(L, ctx, package);
- } else {
- if (uci_list_configs(ctx, &config) != 0)
- goto done;
+ return 1;
+ }
- for(i = 0; config[i] != NULL; i++) {
- uci_lua_changes_pkg(L, ctx, config[i]);
- }
+ if ((uci_list_configs(ctx, &config) != UCI_OK) || !config)
+ return 1;
+
+ for (i = 0; config[i] != NULL; i++) {
+ uci_lua_changes_pkg(L, ctx, config[i]);
}
-done:
+ free(config);
return 1;
}