comparison mercurial/util.py @ 30545: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 39d13b8c101d
children 1112ff99d965
comparison
equal deleted inserted replaced
30544:3899c358b45a 30545:98d7636c4729
3122 3122
3123 def decompressorreader(self, fh): 3123 def decompressorreader(self, fh):
3124 def gen(): 3124 def gen():
3125 d = zlib.decompressobj() 3125 d = zlib.decompressobj()
3126 for chunk in filechunkiter(fh): 3126 for chunk in filechunkiter(fh):
3127 yield d.decompress(chunk) 3127 while chunk:
3128 # Limit output size to limit memory.
3129 yield d.decompress(chunk, 2 ** 18)
3130 chunk = d.unconsumed_tail
3128 3131
3129 return chunkbuffer(gen()) 3132 return chunkbuffer(gen())
3130 3133
3131 compengines.register(_zlibengine()) 3134 compengines.register(_zlibengine())
3132 3135