From 7f927b373e4652af9777748c5e2bce4bddad8da3 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 2 Jun 2020 12:08:08 +0200 Subject: [PATCH] H2 protocol handler: make sure inflateEnd gets called on z-stream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The request/reply pair is created out of QNetworkRequest, we set autoDecompress data-member on the request, but not reply. As a result, reply in its destructor fails to release memory, allocated by z-lib (by failing to call inflateEnd). Since with H1 requests it does not seem to be a problem (no leaks detected), I'm limiting this change to H2 handler only. Later it will be retired by the stream decompression change in Qt 6, but will be picked to 5.15. Fixes: QTBUG-84560 Pick-to: 5.15 Change-Id: I82e19d2b0a83624b730edd20d7d45721e7001731 Reviewed-by: MÃ¥rten Nordheim --- src/network/access/qhttp2protocolhandler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index ac90714132..c8b051731a 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -1209,6 +1209,9 @@ void QHttp2ProtocolHandler::updateStream(Stream &stream, const Frame &frame, QByteDataBuffer inDataBuffer; inDataBuffer.append(wrapped); replyPrivate->uncompressBodyData(&inDataBuffer, &replyPrivate->responseData); + // Now, make sure replyPrivate's destructor will properly clean up + // buffers allocated (if any) by zlib. + replyPrivate->autoDecompress = true; } else { replyPrivate->responseData.append(wrapped); }