Skip to content

Commit

Permalink
fix circular reference, this will introduce memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
yinjiawind committed Apr 27, 2017
1 parent 40dded3 commit 6924afc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions olefile/olefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@

import io
import sys
import weakref
import struct, array, os.path, datetime, logging

#=== COMPATIBILITY WORKAROUNDS ================================================
Expand Down Expand Up @@ -1901,14 +1902,14 @@ def _open(self, start, size = UNKNOWN_SIZE, force_FAT=False):
return OleStream(fp=self.ministream, sect=start, size=size,
offset=0, sectorsize=self.minisectorsize,
fat=self.minifat, filesize=self.ministream.size,
olefileio=self)
olefileio=weakref.ref(self))
else:
# standard stream
return OleStream(fp=self.fp, sect=start, size=size,
offset=self.sectorsize,
sectorsize=self.sectorsize, fat=self.fat,
filesize=self._filesize,
olefileio=self)
olefileio=weakref.ref(self))


def _list(self, files, prefix, node, streams=True, storages=False):
Expand Down

0 comments on commit 6924afc

Please sign in to comment.