Sometimes, decompressing was failing due to miscalculation of buffer
offsets, and hence causing a silent buffer overflow.
When a previous chunk decompression left some bytes in the decryption
buffer, it was not taken into account in determining space left in the
decompression buffer.
So, it could happen, that the decryption buffer is completely full,
but some bytes are not used yet. In such case, even though the buffer
is full, the code tried to decrypt more bytes behind it's boundary.
This CL resolves this issue by properly calculating the amount of
space left in the decompression buffer.
(This is an edited version of Tomasz Mikolajewski's pull request.)