gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.42k stars 512 forks source link

Fix corrupt zips for certain inputs (clean fix) #303

Closed skollmann closed 2 years ago

skollmann commented 2 years ago

This is a cleaner version of the fix in https://github.com/gildas-lormeau/zip.js/pull/302 that separates pending_buf -- which is used simultaneously for 3 different buffers as an optimisation -- into 3 separate arrays. This improves maintainability and readability of the code (reducing the likelihood of introducing bugs such as this one) at the cost of 48 KiB additional memory, which I would argue is a worthwhile trade-off for a JS implementation.

gildas-lormeau commented 2 years ago

Thank you very much for your contribution. I trust you because my skills are very limited on this part of the code. The changes look good to me.