Mercurial > hg
changeset 30536:98d7636c4729
util: limit output chunk size in zlib decompression
This is essentially a port of 65bd4b8e48bd, which was inadvertently
dropped by 8cd7d0fefd30.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 26 Nov 2016 09:07:11 -0800 |
parents | 3899c358b45a |
children | 4b0e6677eed1 |
files | mercurial/util.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Wed Nov 23 18:13:11 2016 +0000 +++ b/mercurial/util.py Sat Nov 26 09:07:11 2016 -0800 @@ -3124,7 +3124,10 @@ def gen(): d = zlib.decompressobj() for chunk in filechunkiter(fh): - yield d.decompress(chunk) + while chunk: + # Limit output size to limit memory. + yield d.decompress(chunk, 2 ** 18) + chunk = d.unconsumed_tail return chunkbuffer(gen())