Commit 6e545fc8d781e3e4974d9370f5bb3f5bd9fbeef8
1 parent
743ad7f4
oleid: ensure olefile is closed
Showing
1 changed file
with
7 additions
and
0 deletions
oletools/oleid.py
| @@ -450,6 +450,10 @@ class OleID(object): | @@ -450,6 +450,10 @@ class OleID(object): | ||
| 450 | vba_indicator.risk = RISK.ERROR | 450 | vba_indicator.risk = RISK.ERROR |
| 451 | vba_indicator.value = 'Error' | 451 | vba_indicator.value = 'Error' |
| 452 | vba_indicator.description = 'Error while checking VBA macros: %s' % str(e) | 452 | vba_indicator.description = 'Error while checking VBA macros: %s' % str(e) |
| 453 | + finally: | ||
| 454 | + if vba_parser is not None: | ||
| 455 | + vba_parser.close() | ||
| 456 | + vba_parser = None | ||
| 453 | # Check XLM macros only for Excel file types: | 457 | # Check XLM macros only for Excel file types: |
| 454 | if self.ftg.is_excel(): | 458 | if self.ftg.is_excel(): |
| 455 | # TODO: for now XLM detection only works for files on disk... So we need to reload VBA_Parser from the filename | 459 | # 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): | @@ -465,6 +469,9 @@ class OleID(object): | ||
| 465 | xlm_indicator.risk = RISK.ERROR | 469 | xlm_indicator.risk = RISK.ERROR |
| 466 | xlm_indicator.value = 'Error' | 470 | xlm_indicator.value = 'Error' |
| 467 | xlm_indicator.description = 'Error while checking XLM macros: %s' % str(e) | 471 | xlm_indicator.description = 'Error while checking XLM macros: %s' % str(e) |
| 472 | + finally: | ||
| 473 | + if vba_parser is not None: | ||
| 474 | + vba_parser.close() | ||
| 468 | else: | 475 | else: |
| 469 | xlm_indicator.risk = RISK.UNKNOWN | 476 | xlm_indicator.risk = RISK.UNKNOWN |
| 470 | xlm_indicator.value = 'Unknown' | 477 | xlm_indicator.value = 'Unknown' |