- n = MIN(toklen, CHUNK_SIZE);
- tx_strm.next_in = (Bytef *) map_ptr(buf, offset, n);
- tx_strm.avail_in = n;
- tx_strm.next_out = (Bytef *)obuf;
+ /* Break up long sections in the same way that
+ * see_deflate_token() does. */
+ int32 n1 = toklen > 0xffff ? 0xffff : toklen;
+ toklen -= n1;
+ tx_strm.next_in = (Bytef *)map_ptr(buf, offset, n1);
+ tx_strm.avail_in = n1;
+ tx_strm.next_out = (Bytef *) obuf;