QZip: fix Coverity warning about reading uninit'ed fields from z_stream
Coverity complains that inflateInit2() will read stream.opaque, which wasn't initialized by us. At least in the copy of zlib that is contained in Qt, this is false. But xxflate() in qbytearray.cpp value-initializes its z_stream (and therefore doesn't manually need to set .zalloc and .zfree), so do that here, too. Amends the start of the public history. Pick-to: 6.8 6.5 Coverity-Id: 310213 Change-Id: I487072a0d2375a932f3ffb9a1f252fec9e2f2d0d Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit a817ba8e9c42dfffd31eb26ac522488c2a4ec61e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
660a63d739
commit
72fddb0935
@ -91,7 +91,7 @@ static void writeMSDosDate(uchar *dest, const QDateTime& dt)
|
||||
|
||||
static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen)
|
||||
{
|
||||
z_stream stream;
|
||||
z_stream stream = {};
|
||||
int err;
|
||||
|
||||
stream.next_in = const_cast<Bytef*>(source);
|
||||
@ -104,9 +104,6 @@ static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourc
|
||||
if ((uLong)stream.avail_out != *destLen)
|
||||
return Z_BUF_ERROR;
|
||||
|
||||
stream.zalloc = (alloc_func)nullptr;
|
||||
stream.zfree = (free_func)nullptr;
|
||||
|
||||
err = inflateInit2(&stream, -MAX_WBITS);
|
||||
if (err != Z_OK)
|
||||
return err;
|
||||
|
Loading…
x
Reference in New Issue
Block a user