PropagateDownload: fix possible crash
authorOlivier Goffart <ogoffart@woboq.com>
Tue, 28 Mar 2017 13:21:59 +0000 (15:21 +0200)
committerMarkus Goetz <markus@woboq.com>
Tue, 28 Mar 2017 16:04:19 +0000 (18:04 +0200)
Backtrace looks like this:
Crash: EXCEPTION_ACCESS_VIOLATION_READ at 0x0
  File "propagatedownload.cpp", line 234, in OCC::GETFileJob::slotReadyRead
  File "moc_propagatedownl_CA5CFSHZDTX34X.cpp", line 86, in OCC::GETFileJob::qt_static_metacall
  File "qobject.cpp", line 495, in QMetaCallEvent::placeMetaCall
  File "qobject.cpp", line 1256, in QObject::event
  File "qapplication.cpp", line 3804, in QApplicationPrivate::notify_helper

GETFileJob::slotReadyRead can be called with a QueuedConnection when the
bendwith manager is involved. In that case, if the QNAM was reset
in between, the reply might have been destroyed.
(This is only speculation based on the backtrace)

src/libsync/propagatedownload.cpp

index f5bc11f5e98501b590bda5273fa437cf3b2c480a..e87e3d45bf2405cc7cfdb83417bf8763277cddb3 100644 (file)
@@ -231,6 +231,8 @@ qint64 GETFileJob::currentDownloadPosition()
 
 void GETFileJob::slotReadyRead()
 {
+    if (!reply())
+        return;
     int bufferSize = qMin(1024*8ll , reply()->bytesAvailable());
     QByteArray buffer(bufferSize, Qt::Uninitialized);