Ticket #46496: Fix-crash-in-QNetworkAccessCacheBackend-closeDownstr.patch

File Fix-crash-in-QNetworkAccessCacheBackend-closeDownstr.patch, 2.3 KB (added by RJVB (René Bertin), 10 years ago)

from Ubuntu

  • qtbase/src/network/access/qnetworkaccesscachebackend.cpp

    From 020fc9e9dcd19ef515e48c96e83fd6f75d52684a Mon Sep 17 00:00:00 2001
    From: Albert Astals Cid <albert.astals@canonical.com>
    Date: Thu, 18 Sep 2014 17:59:51 +0200
    Subject: [PATCH] Fix crash in
     QNetworkAccessCacheBackend::closeDownstreamChannel
    
    device is private, always null and class has no friends, so no need to have it at all
    
    Change-Id: I320d47f1a712a3202c08b494563533e29d185501
    ---
     src/network/access/qnetworkaccesscachebackend.cpp           |  6 ------
     src/network/access/qnetworkaccesscachebackend_p.h           |  1 -
     .../qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp     | 13 +++++++++++++
     3 files changed, 13 insertions(+), 7 deletions(-)
    
     
    5252
    5353QNetworkAccessCacheBackend::QNetworkAccessCacheBackend()
    5454    : QNetworkAccessBackend()
    55     , device(0)
    5655{
    5756}
    5857
     
    125124
    126125void QNetworkAccessCacheBackend::closeDownstreamChannel()
    127126{
    128     if (operation() == QNetworkAccessManager::GetOperation) {
    129         device->close();
    130         delete device;
    131         device = 0;
    132     }
    133127}
    134128
    135129void QNetworkAccessCacheBackend::closeUpstreamChannel()
  • qtbase/src/network/access/qnetworkaccesscachebackend_p.h

     
    7575
    7676private:
    7777    bool sendCacheContents();
    78     QIODevice *device;
    7978
    8079};
    8180
  • qtbase/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp

     
    4242#include <QtTest/QtTest>
    4343
    4444#include <QtNetwork/QNetworkAccessManager>
     45#include <QtNetwork/QNetworkReply>
    4546#ifndef QT_NO_BEARERMANAGEMENT
    4647#include <QtNetwork/QNetworkConfigurationManager>
    4748#endif
     
    6162
    6263private slots:
    6364    void networkAccessible();
     65    void alwaysCacheRequest();
    6466};
    6567
    6668tst_QNetworkAccessManager::tst_QNetworkAccessManager()
     
    126128#endif
    127129}
    128130
     131void tst_QNetworkAccessManager::alwaysCacheRequest()
     132{
     133    QNetworkAccessManager manager;
     134
     135    QNetworkRequest req;
     136    req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
     137    QNetworkReply *reply = manager.get(req);
     138    reply->close();
     139    delete reply;
     140}
     141
    129142QTEST_MAIN(tst_QNetworkAccessManager)
    130143#include "tst_qnetworkaccessmanager.moc"