libs/uci: fix attempt to assign empty tables in uci bind class
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 15 Oct 2009 16:22:03 +0000 (16:22 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 15 Oct 2009 16:22:03 +0000 (16:22 +0000)
libs/uci/luasrc/model/uci/bind.lua

index 89ad328..6f9060d 100644 (file)
@@ -126,7 +126,11 @@ end
 function bsection.set(self, k, v, c)
        local stat
        if type(c) == "string" then
-               stat = self:uciop("set", c, k, v)
+               if type(v) == "table" and #v == 0 then
+                       stat = self:uciop("delete", c, k)
+               else
+                       stat = self:uciop("set", c, k, v)
+               end
        else
                self:uciop("foreach", self.stype,
                        function(s)