diff options
author | Tobias Markmann <tm@ayena.de> | 2016-01-26 15:46:00 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-01-26 15:46:00 (GMT) |
commit | 45828058f4a5e235e9caa9861027f3a9e1682fae (patch) | |
tree | ba5c3d21e48fef99c4d0a67b23524991e119b294 /Swiften | |
parent | 70651c20e9b9640cbf16a4d06fdae4845132045d (diff) | |
download | swift-45828058f4a5e235e9caa9861027f3a9e1682fae.zip swift-45828058f4a5e235e9caa9861027f3a9e1682fae.tar.bz2 |
Fix ASAN reported heap-use-after-free in FileTransferTest
Test-Information:
./scons test=system passes without any ASAN reports on OS X
10.11.3.
Change-Id: I6825414e2f3c5e5aec48289395f44ccdc14d8f95
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/QA/FileTransferTest/FileTransferTest.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Swiften/QA/FileTransferTest/FileTransferTest.cpp b/Swiften/QA/FileTransferTest/FileTransferTest.cpp index 13b6eff..8597033 100644 --- a/Swiften/QA/FileTransferTest/FileTransferTest.cpp +++ b/Swiften/QA/FileTransferTest/FileTransferTest.cpp @@ -96,8 +96,7 @@ class FileTransferTest { delete receiverTracer_; // Free file-transfer objects so file handles are closed and files can be removed afterwards. - incomingFileTransfers_.clear(); - outgoingFileTransfer_.reset(); + assert(!outgoingFileTransfer_ && incomingFileTransfers_.empty()); if(boost::filesystem::exists(sendFilePath_)) { boost::filesystem::remove(sendFilePath_); @@ -189,6 +188,11 @@ class FileTransferTest { if (error) { std::cout << this << " " << "handleSenderDisconnected: error: " << error.get() << std::endl; } + + // All file-transfers related to a Client instance need to be freed + // *before* freeing the Client instance. + outgoingFileTransfer_.reset(); + sender_.reset(); if (!sender_ && !receiver_) { eventLoop->stop(); @@ -199,6 +203,11 @@ class FileTransferTest { if (error) { std::cout << this << " " << "handleReceiverDisconnected: error: " << error.get() << std::endl; } + + // All file-transfers related to a Client instance need to be freed + // *before* freeing the Client instance. + incomingFileTransfers_.clear(); + receiver_.reset(); if (!sender_ && !receiver_) { eventLoop->stop(); |