From 6e545fc8d781e3e4974d9370f5bb3f5bd9fbeef8 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Mon, 4 Oct 2021 10:57:53 +0200 Subject: [PATCH] oleid: ensure olefile is closed --- oletools/oleid.py | 7 +++++++ 1 file changed, 7 insertions(+), 0 deletions(-) diff --git a/oletools/oleid.py b/oletools/oleid.py index 29c4eec..61ce3c2 100644 --- a/oletools/oleid.py +++ b/oletools/oleid.py @@ -450,6 +450,10 @@ class OleID(object): vba_indicator.risk = RISK.ERROR vba_indicator.value = 'Error' vba_indicator.description = 'Error while checking VBA macros: %s' % str(e) + finally: + if vba_parser is not None: + vba_parser.close() + vba_parser = None # Check XLM macros only for Excel file types: if self.ftg.is_excel(): # TODO: for now XLM detection only works for files on disk... So we need to reload VBA_Parser from the filename @@ -465,6 +469,9 @@ class OleID(object): xlm_indicator.risk = RISK.ERROR xlm_indicator.value = 'Error' xlm_indicator.description = 'Error while checking XLM macros: %s' % str(e) + finally: + if vba_parser is not None: + vba_parser.close() else: xlm_indicator.risk = RISK.UNKNOWN xlm_indicator.value = 'Unknown' -- libgit2 0.21.4