Commit f68e2fe6 authored by Benoît Minisini's avatar Benoît Minisini
Browse files

'zlib' inflate function sometimes returns an incorrect error code that lead to a crash.

[GB.COMPRESS.ZLIB]
* BUG: 'zlib' inflate function sometimes returns an incorrect error code that lead to a crash.
parent 4a5e740b
Pipeline #363435699 passed with stage
in 26 minutes and 32 seconds
......@@ -188,9 +188,10 @@ static void u_String(char **target,unsigned int *lent,char *source,unsigned int
.avail_in = len,
.next_in = (Bytef *) source,
};
unsigned long pos = 0;
size_t pos = 0;
*lent = 2 * len;
*lent = 2; // * len;
GB.Alloc((void **) target, *lent);
stream.avail_out = *lent;
......@@ -204,6 +205,8 @@ static void u_String(char **target,unsigned int *lent,char *source,unsigned int
break;
case Z_BUF_ERROR:
pos = (unsigned long) (stream.next_out - (unsigned long) *target);
if (stream.avail_in == 0) // BM: No idea why zlib returns Z_BUF_ERROR and not Z_STREAM_END in that case.
goto out;
*lent += *lent / 2;
GB.Realloc((void **) target, *lent);
stream.avail_out = *lent - pos;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment