diff options
| author | Tobias Markmann <tm@ayena.de> | 2015-06-30 07:02:01 (GMT) |
|---|---|---|
| committer | Kevin Smith <kevin.smith@isode.com> | 2015-07-07 19:58:12 (GMT) |
| commit | 799a7ac203dc2576872894dfdd1adb5cdbbacf7b (patch) | |
| tree | e0242decf49222b83674143cf04f61c3dc01bc35 /Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp | |
| parent | abd96284e162b3594bd0fc90a5da6b78709dee23 (diff) | |
| download | swift-799a7ac203dc2576872894dfdd1adb5cdbbacf7b.zip swift-799a7ac203dc2576872894dfdd1adb5cdbbacf7b.tar.bz2 | |
Fix memory leaks reported by ASAN
Test-Information:
Tested on Elementary OS with a LLVM/Clang 3.7.0 build. With this patch
the reports for the fixed locations are gone.
Change-Id: I0260fc85ad662335a69ace331f51ebe2f864ef97
Diffstat (limited to 'Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp')
| -rw-r--r-- | Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp index aabbd2d..5c18b13 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Copyright (C) 2013-2015 Isode Limited. | 8 | * Copyright (c) 2013-2015 Isode Limited. |
| 9 | * All rights reserved. | 9 | * All rights reserved. |
| 10 | * See the COPYING file for more information. | 10 | * See the COPYING file for more information. |
| 11 | */ | 11 | */ |
| @@ -21,25 +21,24 @@ | |||
| 21 | #include <boost/smart_ptr/make_shared.hpp> | 21 | #include <boost/smart_ptr/make_shared.hpp> |
| 22 | #include <boost/typeof/typeof.hpp> | 22 | #include <boost/typeof/typeof.hpp> |
| 23 | 23 | ||
| 24 | #include <Swiften/Base/foreach.h> | ||
| 25 | #include <Swiften/Base/IDGenerator.h> | 24 | #include <Swiften/Base/IDGenerator.h> |
| 26 | #include <Swiften/Jingle/JingleContentID.h> | 25 | #include <Swiften/Base/Log.h> |
| 27 | #include <Swiften/Jingle/JingleSession.h> | 26 | #include <Swiften/Base/foreach.h> |
| 27 | #include <Swiften/Crypto/CryptoProvider.h> | ||
| 28 | #include <Swiften/Elements/JingleFileTransferDescription.h> | 28 | #include <Swiften/Elements/JingleFileTransferDescription.h> |
| 29 | #include <Swiften/Elements/JingleFileTransferHash.h> | 29 | #include <Swiften/Elements/JingleFileTransferHash.h> |
| 30 | #include <Swiften/Elements/JingleTransportPayload.h> | ||
| 31 | #include <Swiften/Elements/JingleIBBTransportPayload.h> | 30 | #include <Swiften/Elements/JingleIBBTransportPayload.h> |
| 32 | #include <Swiften/Elements/JingleS5BTransportPayload.h> | 31 | #include <Swiften/Elements/JingleS5BTransportPayload.h> |
| 33 | #include <Swiften/FileTransfer/IncrementalBytestreamHashCalculator.h> | 32 | #include <Swiften/Elements/JingleTransportPayload.h> |
| 34 | #include <Swiften/FileTransfer/FileTransferTransporter.h> | 33 | #include <Swiften/FileTransfer/FileTransferTransporter.h> |
| 35 | #include <Swiften/FileTransfer/FileTransferTransporterFactory.h> | 34 | #include <Swiften/FileTransfer/FileTransferTransporterFactory.h> |
| 35 | #include <Swiften/FileTransfer/IncrementalBytestreamHashCalculator.h> | ||
| 36 | #include <Swiften/FileTransfer/ReadBytestream.h> | 36 | #include <Swiften/FileTransfer/ReadBytestream.h> |
| 37 | #include <Swiften/FileTransfer/TransportSession.h> | 37 | #include <Swiften/FileTransfer/TransportSession.h> |
| 38 | #include <Swiften/Crypto/CryptoProvider.h> | 38 | #include <Swiften/Jingle/JingleContentID.h> |
| 39 | #include <Swiften/Jingle/JingleSession.h> | ||
| 39 | #include <Swiften/Network/TimerFactory.h> | 40 | #include <Swiften/Network/TimerFactory.h> |
| 40 | 41 | ||
| 41 | #include <Swiften/Base/Log.h> | ||
| 42 | |||
| 43 | using namespace Swift; | 42 | using namespace Swift; |
| 44 | 43 | ||
| 45 | static const int DEFAULT_BLOCK_SIZE = 4096; | 44 | static const int DEFAULT_BLOCK_SIZE = 4096; |
| @@ -78,11 +77,16 @@ OutgoingJingleFileTransfer::~OutgoingJingleFileTransfer() { | |||
| 78 | stream->onRead.disconnect( | 77 | stream->onRead.disconnect( |
| 79 | boost::bind(&IncrementalBytestreamHashCalculator::feedData, hashCalculator, _1)); | 78 | boost::bind(&IncrementalBytestreamHashCalculator::feedData, hashCalculator, _1)); |
| 80 | delete hashCalculator; | 79 | delete hashCalculator; |
| 80 | hashCalculator = NULL; | ||
| 81 | removeTransporter(); | ||
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | void OutgoingJingleFileTransfer::start() { | 84 | void OutgoingJingleFileTransfer::start() { |
| 84 | SWIFT_LOG(debug) << std::endl; | 85 | SWIFT_LOG(debug) << std::endl; |
| 85 | if (state != Initial) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } | 86 | if (state != Initial) { |
| 87 | SWIFT_LOG(warning) << "Incorrect state" << std::endl; | ||
| 88 | return; | ||
| 89 | } | ||
| 86 | 90 | ||
| 87 | setTransporter(transporterFactory->createInitiatorTransporter(getInitiator(), getResponder(), options)); | 91 | setTransporter(transporterFactory->createInitiatorTransporter(getInitiator(), getResponder(), options)); |
| 88 | setState(GeneratingInitialLocalCandidates); | 92 | setState(GeneratingInitialLocalCandidates); |
| @@ -290,7 +294,7 @@ void OutgoingJingleFileTransfer::stopAll() { | |||
| 290 | case Finished: SWIFT_LOG(warning) << "Already finished" << std::endl; break; | 294 | case Finished: SWIFT_LOG(warning) << "Already finished" << std::endl; break; |
| 291 | } | 295 | } |
| 292 | if (state != Initial) { | 296 | if (state != Initial) { |
| 293 | delete transporter; | 297 | removeTransporter(); |
| 294 | } | 298 | } |
| 295 | } | 299 | } |
| 296 | 300 | ||
Swift