From 4b10b95aac4b5ddaf4460fabdb249195bfcb625b Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Thu, 9 May 2019 14:35:38 +0200 Subject: [PATCH] xls_parser: close XlsFile after use --- oletools/xls_parser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/oletools/xls_parser.py b/oletools/xls_parser.py index 2d501e9..2f0bdad 100644 --- a/oletools/xls_parser.py +++ b/oletools/xls_parser.py @@ -88,12 +88,18 @@ def is_xls(filename): substream. See also: oleid.OleID.check_excel """ + xls_file = None try: - for stream in XlsFile(filename).iter_streams(): + xls_file = XlsFile(filename) + for stream in xls_file.iter_streams(): if isinstance(stream, WorkbookStream): return True except Exception: - pass + logging.debug('Ignoring exception in is_xls, assume is not xls', + exc_info=True) + finally: + if xls_file is not None: + xls_file.close() return False -- libgit2 0.21.4