erocarrera / pefile

pefile is a Python module to read and work with PE (Portable Executable) files
MIT License
1.86k stars 519 forks source link

Fix for 'value' referenced before assignment #342

Closed tfluehmann closed 2 years ago

tfluehmann commented 2 years ago

We faced this issue while unpacking a pefile:

File "/app/venv/lib/python3.6/site-packages/pefile.py", line 2743, in __init__\n    self.__parse__(name, data, fast_load)\n  File "/app/venv/lib/python3.6/site-packages/pefile.py", line 3148, in __parse__\n    self.full_load()\n
File "/app/venv/lib/python3.6/site-packages/pefile.py", line 3259, in full_load\n    self.parse_data_directories()\n
File "/app/venv/lib/python3.6/site-packages/pefile.py", line 3559, in parse_data_directories\n    if value:\nUnboundLocalError: local variable 'value' referenced before assignment\n"

If a PEFormatError exception occurs since the value variable is never assigned and will raise an UnboundLocalError exception in the next if clause.

erocarrera commented 2 years ago

Thanks!