mod_firewall: Ensure file lists are always initialized empty
authorMatthew Wild <mwild1@gmail.com>
Tue, 12 May 2020 12:31:51 +0100
changeset 4021 015452258952
parent 4020 b872f111b7af
child 4022 f27becd421bd
mod_firewall: Ensure file lists are always initialized empty
mod_firewall/definitions.lib.lua
--- a/mod_firewall/definitions.lib.lua	Mon May 11 17:18:30 2020 +0100
+++ b/mod_firewall/definitions.lib.lua	Tue May 12 12:31:51 2020 +0100
@@ -148,8 +148,8 @@
 	-- %LIST: file:/path/to/file
 	file = {
 		init = function (self, file_spec, opts)
-			local items = {};
-			local n = 0;
+			local n, items = 0, {};
+			self.items = items;
 			local filename = file_spec:gsub("^file:", "");
 			if opts.missing == "ignore" and not lfs.attributes(filename, "mode") then
 				module:log("debug", "Ignoring missing list file: %s", filename);
@@ -167,7 +167,6 @@
 					end
 				end
 			end
-			self.items = items;
 			module:log("debug", "Loaded %d items from %s", n, filename);
 		end;
 		add = function (self, item)