Commit 64ec5c94 authored by jocelyn.turcotte@nokia.com's avatar jocelyn.turcotte@nokia.com
Browse files

[Qt] Refactor QNetworkReplyHandler::finish() to prevent crashes.

https://bugs.webkit.org/show_bug.cgi?id=50761

Reviewed by Kenneth Rohde Christiansen.

This patch change the order to check if m_reply is null instead,
explicitly deleting the reply before calling start() for a redirect,
or after calling didFinishLoading()/didFail() in other cases.

* platform/network/qt/QNetworkReplyHandler.cpp:
(WebCore::QNetworkReplyHandler::finish):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73708 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b216401b
2010-12-09 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Qt] Refactor QNetworkReplyHandler::finish() to prevent crashes.
https://bugs.webkit.org/show_bug.cgi?id=50761
This patch change the order to check if m_reply is null instead,
explicitly deleting the reply before calling start() for a redirect,
or after calling didFinishLoading()/didFail() in other cases.
* platform/network/qt/QNetworkReplyHandler.cpp:
(WebCore::QNetworkReplyHandler::finish):
2010-12-09 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2010-12-09 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
Reviewed by Kenneth Rohde Christiansen. Reviewed by Kenneth Rohde Christiansen.
......
...@@ -300,29 +300,33 @@ void QNetworkReplyHandler::finish() ...@@ -300,29 +300,33 @@ void QNetworkReplyHandler::finish()
return; return;
} }
QNetworkReply* oldReply = m_reply; if (!m_redirected) {
if (!m_reply->error() || ignoreHttpError(m_reply, m_responseContainsData)) {
client->didFinishLoading(m_resourceHandle, 0);
} else {
QUrl url = m_reply->url();
int httpStatusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (m_redirected) { if (httpStatusCode) {
resetState(); ResourceError error("HTTP", httpStatusCode, url.toString(), m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString());
start(); client->didFail(m_resourceHandle, error);
} else if (!m_reply->error() || ignoreHttpError(m_reply, m_responseContainsData)) { } else {
client->didFinishLoading(m_resourceHandle, 0); ResourceError error("QtNetwork", m_reply->error(), url.toString(), m_reply->errorString());
client->didFail(m_resourceHandle, error);
}
}
if (m_reply) {
m_reply->deleteLater();
m_reply = 0;
}
} else { } else {
QUrl url = m_reply->url(); if (m_reply) {
int httpStatusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); m_reply->deleteLater();
m_reply = 0;
if (httpStatusCode) {
ResourceError error("HTTP", httpStatusCode, url.toString(), m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString());
client->didFail(m_resourceHandle, error);
} else {
ResourceError error("QtNetwork", m_reply->error(), url.toString(), m_reply->errorString());
client->didFail(m_resourceHandle, error);
} }
resetState();
start();
} }
oldReply->deleteLater();
if (oldReply == m_reply)
m_reply = 0;
} }
void QNetworkReplyHandler::sendResponseIfNeeded() void QNetworkReplyHandler::sendResponseIfNeeded()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment