Commit 371f366d by devttys0

Removed unused custom __del__ methods to prevent memory leaks

parent 253da78e
...@@ -245,9 +245,6 @@ class Module(object): ...@@ -245,9 +245,6 @@ class Module(object):
except AttributeError as e: except AttributeError as e:
pass pass
def __del__(self):
return None
def __enter__(self): def __enter__(self):
return self return self
......
...@@ -25,7 +25,7 @@ class Plugin(object): ...@@ -25,7 +25,7 @@ class Plugin(object):
Returns None. Returns None.
''' '''
self.module = module self.module = module
if not self.MODULES or self.module.name in self.MODULES: if not self.MODULES or self.module.name in self.MODULES:
self._enabled = True self._enabled = True
self.init() self.init()
...@@ -79,8 +79,8 @@ class Plugins(object): ...@@ -79,8 +79,8 @@ class Plugins(object):
The contents of this dictionary key may be modified as necessary by the plugin. The contents of this dictionary key may be modified as necessary by the plugin.
o callback(self, results) o callback(self, results)
This method is called every time a valid result is found in the file being scanned. It is passed a This method is called every time a valid result is found in the file being scanned. It is passed a
dictionary of results. This dictionary is identical to that passed to Binwalk.single_scan's callback dictionary of results. This dictionary is identical to that passed to Binwalk.single_scan's callback
function, and its contents may be modified as necessary by the plugin. function, and its contents may be modified as necessary by the plugin.
o post_scan(self, fd) o post_scan(self, fd)
...@@ -91,7 +91,7 @@ class Plugins(object): ...@@ -91,7 +91,7 @@ class Plugins(object):
Values returned by callback affect only that specific scan result. Values returned by callback affect only that specific scan result.
Values returned by post_scan are ignored since the scan of that file has already been completed. Values returned by post_scan are ignored since the scan of that file has already been completed.
By default, all plugins are loaded during binwalk signature scans. Plugins that wish to be disabled by By default, all plugins are loaded during binwalk signature scans. Plugins that wish to be disabled by
default may create a class variable named 'ENABLED' and set it to False. If ENABLED is set to False, the default may create a class variable named 'ENABLED' and set it to False. If ENABLED is set to False, the
plugin will only be loaded if it is explicitly named in the plugins whitelist. plugin will only be loaded if it is explicitly named in the plugins whitelist.
''' '''
...@@ -108,9 +108,6 @@ class Plugins(object): ...@@ -108,9 +108,6 @@ class Plugins(object):
self.parent = parent self.parent = parent
self.settings = binwalk.core.settings.Settings() self.settings = binwalk.core.settings.Settings()
def __del__(self):
pass
def __enter__(self): def __enter__(self):
return self return self
...@@ -182,8 +179,8 @@ class Plugins(object): ...@@ -182,8 +179,8 @@ class Plugins(object):
for file_name in os.listdir(plugins[key]['path']): for file_name in os.listdir(plugins[key]['path']):
if file_name.endswith(self.MODULE_EXTENSION): if file_name.endswith(self.MODULE_EXTENSION):
module = file_name[:-len(self.MODULE_EXTENSION)] module = file_name[:-len(self.MODULE_EXTENSION)]
try: try:
plugin = imp.load_source(module, os.path.join(plugins[key]['path'], file_name)) plugin = imp.load_source(module, os.path.join(plugins[key]['path'], file_name))
plugin_class = self._find_plugin_class(plugin) plugin_class = self._find_plugin_class(plugin)
...@@ -194,7 +191,7 @@ class Plugins(object): ...@@ -194,7 +191,7 @@ class Plugins(object):
except Exception as e: except Exception as e:
binwalk.core.common.warning("Error loading plugin '%s': %s" % (file_name, str(e))) binwalk.core.common.warning("Error loading plugin '%s': %s" % (file_name, str(e)))
plugins[key]['enabled'][module] = False plugins[key]['enabled'][module] = False
try: try:
plugins[key]['descriptions'][module] = plugin_class.__doc__.strip().split('\n')[0] plugins[key]['descriptions'][module] = plugin_class.__doc__.strip().split('\n')[0]
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
...@@ -245,7 +242,7 @@ class Plugins(object): ...@@ -245,7 +242,7 @@ class Plugins(object):
raise e raise e
except Exception as e: except Exception as e:
pass pass
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
raise e raise e
except Exception as e: except Exception as e:
......
...@@ -124,20 +124,6 @@ class General(Module): ...@@ -124,20 +124,6 @@ class General(Module):
def reset(self): def reset(self):
pass pass
#for fp in self.target_files:
# fp.reset()
def __del__(self):
self._cleanup()
def __exit__(self, a, b, c):
self._cleanup()
def _cleanup(self):
pass
#if hasattr(self, 'target_files'):
# for fp in self.target_files:
# fp.close()
def _set_verbosity(self): def _set_verbosity(self):
''' '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment