3
0
Fork 0

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.
small_fixes
Matthieu Gautier 9 years ago
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…
Cancel
Save