If Registry() is called and initialization fails (for instance, the given file does not exist), the not initialized instanced will be destroyed, and __del__() calls close() which calls self.fd.close(), raising an AttributeError.
This fixes this situation.
Sample code to reproduce
from impacket.winregistry import Registry
try:
reg = Registry('This file does not exist', isRemote = False)
except FileNotFoundError:
pass
expected result
nothing
Actual result
Exception ignored in: <function Registry.__del__ at 0x7706ebe50a40>
Traceback (most recent call last):
File "/home/didier/Tools/impacket/impacket/winregistry.py", line 183, in __del__
self.close()
File "/home/didier/Tools/impacket/impacket/winregistry.py", line 180, in close
self.fd.close()
^^^^^^^
AttributeError: 'Registry' object has no attribute 'fd'
If
Registry()
is called and initialization fails (for instance, the given file does not exist), the not initialized instanced will be destroyed, and__del__()
calls close() which callsself.fd.close()
, raising an AttributeError. This fixes this situation.Sample code to reproduce
expected result
nothing
Actual result
Actual result after fix
nothing