changeset 4017:015452258952

mod_firewall: Ensure file lists are always initialized empty
author Matthew Wild <mwild1@gmail.com>
date Tue, 12 May 2020 12:31:51 +0100
parents b872f111b7af
children f27becd421bd
files mod_firewall/definitions.lib.lua
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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)