util: limit output chunk size in zlib decompression
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 26 Nov 2016 09:07:11 -0800
changeset 30536 98d7636c4729
parent 30535 3899c358b45a
child 30537 4b0e6677eed1
util: limit output chunk size in zlib decompression This is essentially a port of 65bd4b8e48bd, which was inadvertently dropped by 8cd7d0fefd30.
mercurial/util.py
--- 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())