mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-23 03:52:35 -04:00
Correctly check that compress gone well before using the result buffer.
We need to check the return code of compress. Compress may fail for different reason, one being that the compr_buffer is not large enough.
This commit is contained in:
parent
3592cd84c6
commit
e27ce444c6
@ -166,9 +166,9 @@ bool compress_content(string &content,
|
||||
pthread_mutex_lock(&compressorLock);
|
||||
compr_buffer.reserve(COMPRESSOR_BUFFER_SIZE);
|
||||
uLongf comprLen = COMPRESSOR_BUFFER_SIZE;
|
||||
compress(&compr_buffer[0], &comprLen, (const Bytef*)(content.data()), contentLength);
|
||||
int err = compress(&compr_buffer[0], &comprLen, (const Bytef*)(content.data()), contentLength);
|
||||
|
||||
if (comprLen > 2 && comprLen < (contentLength+2)) {
|
||||
if (err == Z_OK && comprLen > 2 && comprLen < (contentLength+2)) {
|
||||
|
||||
/* /!\ Internet Explorer has a bug with deflate compression.
|
||||
It can not handle the first two bytes (compression headers)
|
||||
|
Loading…
x
Reference in New Issue
Block a user