@@ -332,6 +332,7 @@ private Q_SLOTS:
332
332
void qtbug15311doubleContentLength ();
333
333
334
334
void qtbug18232gzipContentLengthZero ();
335
+ void nb279420gzipNoContentLengthEmptyContentDisconnect ();
335
336
336
337
void synchronousRequest_data ();
337
338
void synchronousRequest ();
@@ -5307,6 +5308,28 @@ void tst_QNetworkReply::qtbug18232gzipContentLengthZero()
5307
5308
QCOMPARE (reply->readAll (), QByteArray ());
5308
5309
}
5309
5310
5311
+ // Reproduced a crash in QHttpNetworkReplyPrivate::gunzipBodyPartiallyEnd
5312
+ // where zlib inflateEnd was called for uninitialized zlib stream
5313
+ void tst_QNetworkReply::nb279420gzipNoContentLengthEmptyContentDisconnect ()
5314
+ {
5315
+ // Response with no Content-Length in header and empty content
5316
+ QByteArray response (" HTTP/1.0 200 OK\r\n Content-Encoding: gzip\r\n\r\n " );
5317
+ MiniHttpServer server (response);
5318
+ server.doClose = true ;
5319
+
5320
+ QNetworkRequest request (QUrl (" http://localhost:" + QString::number (server.serverPort ())));
5321
+ QNetworkReplyPtr reply = manager.get (request);
5322
+
5323
+ connect (reply, SIGNAL (finished ()), &QTestEventLoop::instance (), SLOT (exitLoop ()));
5324
+ QTestEventLoop::instance ().enterLoop (10 );
5325
+ QVERIFY (!QTestEventLoop::instance ().timeout ());
5326
+ QVERIFY (reply->isFinished ());
5327
+ QCOMPARE (reply->error (), QNetworkReply::NoError);
5328
+ QCOMPARE (reply->size (), qint64 (0 ));
5329
+ QVERIFY (!reply->header (QNetworkRequest::ContentLengthHeader).isValid ());
5330
+ QCOMPARE (reply->readAll (), QByteArray ());
5331
+ }
5332
+
5310
5333
void tst_QNetworkReply::synchronousRequest_data ()
5311
5334
{
5312
5335
QTest::addColumn<QUrl>(" url" );
0 commit comments