summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-06-19 12:45:31 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-07-08 07:08:08 (GMT)
commita2b065eb22755f9341c58096805875021faffa67 (patch)
tree0283b12cc160260e5b1c04d377dbab6ebef7fe36 /Swiften
parent07544ee46ffda935714dfc36e5bc5582a7d8c2b0 (diff)
downloadswift-a2b065eb22755f9341c58096805875021faffa67.zip
swift-a2b065eb22755f9341c58096805875021faffa67.tar.bz2
Stop timer when SOCKS5BytestreamClientSession is deleted
ASAN reported heap-use-after-free because if the timer is running and an instance is freed, the signal of the timer is still emitted and connected slots are called. Test-Information: Tested that the ASAN report wents away with this fix. Change-Id: Id785737c4c015e5c638e9d9f6419d740d6cf83b9
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp7
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamClientSession.h18
2 files changed, 16 insertions, 9 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
index 4a0cd67..04d5d86 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
@@ -16,13 +16,13 @@
#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/Algorithm.h>
-#include <Swiften/Base/SafeByteArray.h>
+#include <Swiften/Base/ByteArray.h>
#include <Swiften/Base/Concat.h>
#include <Swiften/Base/Log.h>
-#include <Swiften/StringCodecs/Hexify.h>
+#include <Swiften/Base/SafeByteArray.h>
#include <Swiften/FileTransfer/BytestreamException.h>
#include <Swiften/Network/TimerFactory.h>
-#include <Swiften/Base/ByteArray.h>
+#include <Swiften/StringCodecs/Hexify.h>
namespace Swift {
@@ -42,6 +42,7 @@ SOCKS5BytestreamClientSession::SOCKS5BytestreamClientSession(
}
SOCKS5BytestreamClientSession::~SOCKS5BytestreamClientSession() {
+ weFailedTimeout->stop();
}
void SOCKS5BytestreamClientSession::start() {
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h
index cf731c1..1c0563a 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h
@@ -4,16 +4,22 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
#pragma once
-#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
+#include <boost/shared_ptr.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/FileTransfer/FileTransferError.h>
-#include <Swiften/FileTransfer/WriteBytestream.h>
#include <Swiften/FileTransfer/ReadBytestream.h>
+#include <Swiften/FileTransfer/WriteBytestream.h>
#include <Swiften/JID/JID.h>
#include <Swiften/Network/Connection.h>
#include <Swiften/Network/HostAddressPort.h>
@@ -96,10 +102,10 @@ private:
Timer::ref weFailedTimeout;
- boost::bsignals::connection connectFinishedConnection;
- boost::bsignals::connection dataWrittenConnection;
- boost::bsignals::connection dataReadConnection;
- boost::bsignals::connection disconnectedConnection;
+ boost::bsignals::scoped_connection connectFinishedConnection;
+ boost::bsignals::scoped_connection dataWrittenConnection;
+ boost::bsignals::scoped_connection dataReadConnection;
+ boost::bsignals::scoped_connection disconnectedConnection;
};
}