Skip to content

Commit dc9c4a9

Browse files
author
Qt Continuous Integration System
committed
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Fix NB#290352 Qtwebprocess crashes @ QHttpNetworkReply::readAny
2 parents f485ac0 + b070ad6 commit dc9c4a9

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/network/access/qnetworkaccesshttpbackend.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,12 @@ void QNetworkAccessHttpBackend::readFromHttp()
721721
if (!httpReply)
722722
return;
723723

724+
if (!http) {
725+
// Connection has been destroyed
726+
finished();
727+
return;
728+
}
729+
724730
// We read possibly more than nextDownstreamBlockSize(), but
725731
// this is not a critical thing since it is already in the
726732
// memory anyway

tests/auto/qnetworkreply/tst_qnetworkreply.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ private Q_SLOTS:
317317
void getAndThenDeleteObject_data();
318318
void getAndThenDeleteObject();
319319

320+
void deleteManagerWhileGetIsInProgress();
321+
320322
void symbianOpenCDataUrlCrash();
321323

322324
void qtbug12908compressedHttpReply();
@@ -5109,6 +5111,48 @@ void tst_QNetworkReply::getAndThenDeleteObject()
51095111
}
51105112
}
51115113

5114+
void tst_QNetworkReply::deleteManagerWhileGetIsInProgress()
5115+
{
5116+
// yes, this will leak if the testcase fails. I don't care. It must not fail then :P
5117+
QNetworkAccessManager *manager = new QNetworkAccessManager();
5118+
QNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile");
5119+
QNetworkReply *reply = manager->get(request);
5120+
reply->setReadBufferSize(1024);
5121+
5122+
// Reset reply's parent to allow it to outlive the manager
5123+
reply->setParent(0);
5124+
5125+
// Wait until a buffer is received
5126+
int totalWait = 0;
5127+
while (!reply->bytesAvailable()) {
5128+
QTest::qWait(20);
5129+
totalWait += 20;
5130+
QVERIFY( totalWait <= 5*1000);
5131+
}
5132+
5133+
QVERIFY(reply->bytesAvailable());
5134+
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
5135+
QVERIFY(!reply->isFinished()); // must not be finished
5136+
5137+
// Read the data to request next buffer's worth from the server
5138+
(void)reply->readAll();
5139+
5140+
QSignalSpy replyFinishedSpy(reply, SIGNAL(finished()));
5141+
5142+
// Delete the manager
5143+
delete manager;
5144+
manager = 0;
5145+
5146+
// Wait to allow reply to process any pending events
5147+
QTest::qWait(100);
5148+
5149+
// The reply should be finished
5150+
QVERIFY(reply->isFinished());
5151+
QCOMPARE(replyFinishedSpy.count(), 1);
5152+
5153+
delete reply;
5154+
}
5155+
51125156
// see https://bugs.webkit.org/show_bug.cgi?id=38935
51135157
void tst_QNetworkReply::symbianOpenCDataUrlCrash()
51145158
{

0 commit comments

Comments
 (0)