From 0729d364ca25007950c82431b89080416ac4fafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Mat=C4=9Bna?= Date: Sat, 10 Sep 2016 22:48:30 +0200 Subject: [PATCH] Fix double free in DummyConnectionServer Do not create shared ptr from this as this lead to double free in UserRegistryTest::login test. Shared ptr was needed to set event owner in acceptConnection, actually it is never needed as events are never filtered by owner. Thus it was removed and there is no need to create shared ptr from this. --- include/Swiften/Network/DummyConnectionServer.cpp | 3 +-- include/Swiften/Network/DummyConnectionServer.h | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/Swiften/Network/DummyConnectionServer.cpp b/include/Swiften/Network/DummyConnectionServer.cpp index bd84ca0f..8bce4f18 100644 --- a/include/Swiften/Network/DummyConnectionServer.cpp +++ b/include/Swiften/Network/DummyConnectionServer.cpp @@ -30,8 +30,7 @@ void DummyConnectionServer::stop() { void DummyConnectionServer::acceptConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr connection) { eventLoop->postEvent( - boost::bind(boost::ref(onNewConnection), connection), - SWIFTEN_SHRPTR_NAMESPACE::shared_ptr(this)); + boost::bind(boost::ref(onNewConnection), connection)); // connection->listen(); } diff --git a/include/Swiften/Network/DummyConnectionServer.h b/include/Swiften/Network/DummyConnectionServer.h index bbd2ef0d..7472eafc 100644 --- a/include/Swiften/Network/DummyConnectionServer.h +++ b/include/Swiften/Network/DummyConnectionServer.h @@ -19,10 +19,8 @@ #include "Swiften/SwiftenCompat.h" namespace Swift { - class DummyConnectionServer : public ConnectionServer, public EventOwner, public boost::enable_shared_from_this { + class DummyConnectionServer : public ConnectionServer { public: - typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr ref; - enum Error { Conflict, UnknownError