Hi ports@,

I'd like to add the following patch from upstream to mail/trojita. It
fixes a crash that can occur when downloading an attachment in
combination with a recent version of Qt.

Tested on amd64.

Thanks,
Caspar Schutijser


Index: Makefile
===================================================================
RCS file: /cvs/ports/mail/trojita/Makefile,v
retrieving revision 1.32
diff -u -p -r1.32 Makefile
--- Makefile    28 Feb 2020 19:30:31 -0000      1.32
+++ Makefile    13 Mar 2020 20:27:37 -0000
@@ -3,7 +3,7 @@
 COMMENT =              fast Qt IMAP e-mail client
 
 DISTNAME =             trojita-0.7
-REVISION =             10
+REVISION =             11
 
 SHARED_LIBS =          trojita_plugins 2.0 # 2.0
 
Index: patches/patch-src_Imap_Network_FileDownloadManager_cpp
===================================================================
RCS file: patches/patch-src_Imap_Network_FileDownloadManager_cpp
diff -N patches/patch-src_Imap_Network_FileDownloadManager_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_Imap_Network_FileDownloadManager_cpp      13 Mar 2020 
20:27:37 -0000
@@ -0,0 +1,45 @@
+$OpenBSD$
+
+https://cgit.kde.org/trojita.git/commit/?id=cf2364b80fa8ae844df8350cd5833d47cce235f2
+
+commit cf2364b80fa8ae844df8350cd5833d47cce235f2
+Author: Jan Kundrát <[email protected]>
+Date:   Mon Mar 9 08:24:48 2020 -0700
+
+    Fix possible crash when downloading attachments
+    
+    Turns out we've been happily deleting network replies from the
+    QNetworkReply::finished(). That was never a good thing to do, but it did
+    not use to crash with older Qt. Now it does.
+    
+    [...]
+
+Index: src/Imap/Network/FileDownloadManager.cpp
+--- src/Imap/Network/FileDownloadManager.cpp.orig
++++ src/Imap/Network/FileDownloadManager.cpp
+@@ -139,7 +139,9 @@ void FileDownloadManager::downloadMessage()
+ 
+ void FileDownloadManager::onPartDataTransfered()
+ {
+-    Q_ASSERT(reply);
++    if (!reply) {
++        return;
++    }
+     if (reply->error() == QNetworkReply::NoError) {
+         if (!saving.open(QIODevice::WriteOnly)) {
+             emit transferError(saving.errorString());
+@@ -192,11 +194,11 @@ void FileDownloadManager::onCombinerTransferError(cons
+ 
+ void FileDownloadManager::deleteReply(QNetworkReply *reply)
+ {
+-    if (reply == this->reply) {
++    if (reply && reply == this->reply) {
+         if (!saved)
+             onPartDataTransfered();
+-        delete reply;
+-        this->reply = 0;
++        reply->deleteLater();
++        this->reply = nullptr;
+     }
+ }
+ 

Reply via email to