From 61d8f281d5f6e339ad497c1f06e4e4e2f306fe43 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 29 Jun 2009 15:38:12 +0200 Subject: QNetworkAccessManager stuff: Some fixes for coverity A few "fixes" to make that number go down.. Reviewed-by: Thiago Macieira --- src/network/access/qhttpnetworkconnection.cpp | 10 +++++++--- src/network/access/qhttpnetworkconnection_p.h | 3 ++- src/network/access/qnetworkreplyimpl.cpp | 6 ++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 4c08794..726b954 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -135,7 +135,9 @@ int QHttpNetworkConnectionPrivate::indexOf(QAbstractSocket *socket) const for (int i = 0; i < channelCount; ++i) if (channels[i].socket == socket) return i; - return -1; + + qFatal("Called with unknown socket object."); + return 0; } bool QHttpNetworkConnectionPrivate::isSocketBusy(QAbstractSocket *socket) const @@ -515,7 +517,7 @@ void QHttpNetworkConnectionPrivate::receiveReply(QAbstractSocket *socket, QHttpN // try to reconnect/resend before sending an error. if (channels[i].reconnectAttempts-- > 0) { resendCurrentRequest(socket); - } else { + } else if (reply) { reply->d_func()->errorString = errorDetail(QNetworkReply::RemoteHostClosedError, socket); emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString); QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); @@ -788,6 +790,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, Q_ASSERT(socket); int i = indexOf(socket); + if (channels[i].authMehtod != QAuthenticatorPrivate::None) { if (!(channels[i].authMehtod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 401)) { QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator); @@ -1322,7 +1325,8 @@ void QHttpNetworkConnectionPrivate::_q_encrypted() QAbstractSocket *socket = qobject_cast(q->sender()); if (!socket) return; // ### error - channels[indexOf(socket)].state = IdleState; + int i = indexOf(socket); + channels[i].state = IdleState; sendRequest(socket); } diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 04609cf..feb974c 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -244,7 +244,8 @@ public: #ifndef QT_NO_OPENSSL bool ignoreSSLErrors; #endif - Channel() :state(IdleState), reply(0), written(0), bytesTotal(0), resendCurrent(false), reconnectAttempts(2), + Channel() : socket(0), state(IdleState), reply(0), written(0), bytesTotal(0), resendCurrent(false), + lastStatus(0), pendingEncrypt(false), reconnectAttempts(2), authMehtod(QAuthenticatorPrivate::None), proxyAuthMehtod(QAuthenticatorPrivate::None) #ifndef QT_NO_OPENSSL , ignoreSSLErrors(false) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index d903d03..63a9c2d 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -52,10 +52,12 @@ QT_BEGIN_NAMESPACE inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate() - : copyDevice(0), networkCache(0), + : backend(0), outgoingData(0), + copyDevice(0), networkCache(0), cacheEnabled(false), cacheSaveDevice(0), notificationHandlingPaused(false), bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1), + httpStatusCode(0), state(Idle) { } @@ -129,7 +131,7 @@ void QNetworkReplyImplPrivate::_q_sourceReadChannelFinished() void QNetworkReplyImplPrivate::_q_copyReadyRead() { Q_Q(QNetworkReplyImpl); - if (!copyDevice && !q->isOpen()) + if (!copyDevice || !q->isOpen()) return; forever { -- cgit v0.12