ZCodec::Compress read a fresh chunk over whatever deflate had left unconsumed. deflate stops as soon as its output buffer is full, and the write-back that frees that buffer only ran at the top of the next iteration, by which time the tail of the previous chunk was gone. Nothing said so. EndCompression answers with the number of bytes taken and no caller compared it, so the result was a shorter document than the one handed in, compressed perfectly well. Passing 100000 bytes through a 64 byte output buffer took 49152 of them. Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com> Change-Id: I1044a46aa1d1f424e7d699a927e01a8427768919 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13208 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins CPCI <releng@collaboraoffice.com> (cherry picked from commit 23e2e9c2136d8b5c9fd6d9604bccd35e9b657571) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211555 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>