mirror of https://github.com/vitalif/phantomjs
Fix potential crash in the reply proxy.
The cause is not clear, either the object ownership issue (circular reference) or some race condition (or worse, both combination). In all cases, using QPointer avoids dereferencing a null object. http://code.google.com/p/phantomjs/issues/detail?id=1581.3
parent
7a9b6b4fec
commit
37404ba179
|
@ -57,7 +57,8 @@ NetworkReplyProxy::NetworkReplyProxy(QObject* parent, QNetworkReply* reply)
|
||||||
|
|
||||||
NetworkReplyProxy::~NetworkReplyProxy()
|
NetworkReplyProxy::~NetworkReplyProxy()
|
||||||
{
|
{
|
||||||
delete m_reply;
|
if (m_reply)
|
||||||
|
delete m_reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NetworkReplyProxy::body()
|
QString NetworkReplyProxy::body()
|
||||||
|
@ -66,13 +67,15 @@ QString NetworkReplyProxy::body()
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkReplyProxy::abort()
|
void NetworkReplyProxy::abort()
|
||||||
{
|
{
|
||||||
m_reply->abort();
|
if (m_reply)
|
||||||
|
m_reply->abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkReplyProxy::close()
|
void NetworkReplyProxy::close()
|
||||||
{
|
{
|
||||||
m_reply->close();
|
if (m_reply)
|
||||||
|
m_reply->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkReplyProxy::isSequential() const
|
bool NetworkReplyProxy::isSequential() const
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#define NETWORKREPLYPROXY_H
|
#define NETWORKREPLYPROXY_H
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
class NetworkReplyProxy : public QNetworkReply {
|
class NetworkReplyProxy : public QNetworkReply {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -60,7 +61,7 @@ public Q_SLOTS:
|
||||||
void readInternal();
|
void readInternal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QNetworkReply* m_reply;
|
QPointer<QNetworkReply> m_reply;
|
||||||
QByteArray m_data;
|
QByteArray m_data;
|
||||||
QByteArray m_buffer;
|
QByteArray m_buffer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue