Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Close files after read

Brendan Coles1dde235d1297
diff --git a/sflib.py b/sflib.py
index e42f40ec..22c7a8f4 100644
--- a/sflib.py
+++ b/sflib.py
@@ -105,6 +105,7 @@ class SpiderFoot:
try:
self.info("Loading configuration data from: " + fname)
f = open(fname, "r")
+
if splitLines:
arr = f.readlines()
ret = list()
@@ -112,6 +113,8 @@ class SpiderFoot:
ret.append(x.rstrip('\n'))
else:
ret = f.read()
+
+ f.close()
return ret
except BaseException as b:
if fatal:
@@ -849,6 +852,7 @@ class SpiderFoot:
try:
wdct = open(self.myPath() + "/dicts/ispell/" + d + ".dict", 'r')
dlines = wdct.readlines()
+ wdct.close()
except BaseException as e:
self.debug("Could not read dictionary: " + str(e))
continue
@@ -869,6 +873,7 @@ class SpiderFoot:
try:
wdct = open(self.myPath() + "/dicts/ispell/" + d + ".dict", 'r')
dlines = wdct.readlines()
+ wdct.close()
except BaseException as e:
self.debug("Could not read dictionary: " + str(e))
continue