Commit 55d99269179807bb918c76e658f41035bddc536d

Authored by Christian Herdtweck
1 parent f7a39579

olevba: close() the VBA_Parser

So glad we have the unittests, otherwise would never have found this
Showing 1 changed file with 6 additions and 0 deletions
oletools/olevba.py
... ... @@ -4474,6 +4474,8 @@ def process_file(filename, data, container, options, crypto_nesting=0):
4474 4474 Returns a single code summarizing the status of processing of this file
4475 4475 """
4476 4476 try:
  4477 + vba_parser = None
  4478 +
4477 4479 # Open the file
4478 4480 vba_parser = VBA_Parser_CLI(filename, data=data, container=container,
4479 4481 relaxed=options.relaxed,
... ... @@ -4501,6 +4503,7 @@ def process_file(filename, data, container, options, crypto_nesting=0):
4501 4503 no_xlm=options.no_xlm))
4502 4504 else: # (should be impossible)
4503 4505 raise ValueError('unexpected output mode: "{0}"!'.format(options.output_mode))
  4506 + vba_parser.close()
4504 4507  
4505 4508 # even if processing succeeds, file might still be encrypted
4506 4509 log.debug('Checking for encryption (normal)')
... ... @@ -4508,6 +4511,9 @@ def process_file(filename, data, container, options, crypto_nesting=0):
4508 4511 log.debug('no encryption detected')
4509 4512 return RETURN_OK
4510 4513 except Exception as exc:
  4514 + if vba_parser:
  4515 + vba_parser.close()
  4516 +
4511 4517 log.debug('Checking for encryption (after exception)')
4512 4518 if crypto.is_encrypted(filename):
4513 4519 pass # deal with this below
... ...