As reported by @tonghuaroot:
zipfile.ZipExtFile._read1() bounds the output of each decompress() call for DEFLATE members (it passes a max_length to zlib), but for bzip2 / LZMA / Zstandard members it called self._decompressor.decompress(data) with no bound. A whole compressed chunk was therefore expanded into a single allocation before the data = data[:self._left] clip ran.
Linked PRs
As reported by @tonghuaroot:
zipfile.ZipExtFile._read1()bounds the output of eachdecompress()call for DEFLATE members (it passes amax_lengthtozlib), but for bzip2 / LZMA / Zstandard members it calledself._decompressor.decompress(data)with no bound. A whole compressed chunk was therefore expanded into a single allocation before thedata = data[:self._left]clip ran.Linked PRs