util: limit output chunk size in zlib decompression
This is essentially a port of
65bd4b8e48bd, which was inadvertently
dropped by
8cd7d0fefd30.
--- 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())