Fix stack overflow in zlib decompress routine.

This commit is contained in:
momo5502 2016-01-09 16:02:54 +01:00
parent 7974bd5cd0
commit 4a0c4ec609

View File

@ -50,11 +50,11 @@ namespace Utils
if (inflateInit(&stream) != Z_OK)
{
return buffer;
return "";
}
int ret = 0;
uint8_t dest[CHUNK] = { 0 };
uint8_t* dest = new uint8_t[CHUNK];
const char* dataPtr = data.data();
do
@ -71,6 +71,8 @@ namespace Utils
if (ret == Z_STREAM_ERROR)
{
inflateEnd(&stream);
delete[] dest;
return "";
}
buffer.append(reinterpret_cast<const char*>(dest), CHUNK - stream.avail_out);
@ -81,6 +83,8 @@ namespace Utils
inflateEnd(&stream);
delete[] dest;
return buffer;
}
};