From 6a7911e4bd9c224ba934eca5d6157de2e57d20e7 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Mon, 15 Apr 2019 11:22:12 +0200 Subject: [PATCH] olevba: Make clean-up more error-proof --- oletools/olevba.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/oletools/olevba.py b/oletools/olevba.py index daf6b0f..d8da451 100644 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -4062,8 +4062,13 @@ def process_file(filename, data, container, options, crypto_nesting=0): except Exception: raise finally: # clean up - if decrypted_file is not None and os.path.isfile(decrypted_file): + try: + log.debug('Removing crypt temp file {}'.format(decrypted_file)) os.unlink(decrypted_file) + except Exception: # e.g. file does not exist or is None + pass + # no idea what to return now + raise Exception('Programming error -- should never have reached this!') def main(cmd_line_args=None): -- libgit2 0.21.4