Ticket #58218: patch-httpsockeng-fix.diff

File patch-httpsockeng-fix.diff, 1.2 KB (added by RJVB (René Bertin), 5 years ago)

prevent a crash that I've seen with OSSL 1.1 but not with OSSL 1.0

  • qtbase/src/network/socket/qhttpsocketengine.cpp

    diff --git a/qtbase/src/network/socket/qhttpsocketengine.cpp b/qtbase/src/network/socket/qhttpsocketengine.cpp
    index dfeb8c7e..43c25dbd 100644
    a b qint64 QHttpSocketEngine::bytesAvailable() const 
    229229qint64 QHttpSocketEngine::read(char *data, qint64 maxlen)
    230230{
    231231    Q_D(QHttpSocketEngine);
     232    if (!d->socket) {
     233        setError(QAbstractSocket::OperationError,
     234                 QLatin1String("TCP socket not connected"));
     235        setState(QAbstractSocket::UnconnectedState);
     236        return -1;
     237    }
    232238    qint64 bytesRead = d->socket->read(data, maxlen);
    233239
    234240    if (d->socket->state() == QAbstractSocket::UnconnectedState
    qint64 QHttpSocketEngine::read(char *data, qint64 maxlen) 
    252258qint64 QHttpSocketEngine::write(const char *data, qint64 len)
    253259{
    254260    Q_D(QHttpSocketEngine);
    255     return d->socket->write(data, len);
     261    if (d->socket) {
     262        return d->socket->write(data, len);
     263    } else {
     264        setError(QAbstractSocket::OperationError,
     265                 QLatin1String("TCP socket not connected"));
     266        setState(QAbstractSocket::UnconnectedState);
     267        return -1;
     268    }
    256269}
    257270
    258271#ifndef QT_NO_UDPSOCKET