From 0729d364ca25007950c82431b89080416ac4fafb 2016-09-16 23:45:34 From: Vladimír Matěna Date: 2016-09-16 23:45:34 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. --- diff --git a/include/Swiften/Network/DummyConnectionServer.cpp b/include/Swiften/Network/DummyConnectionServer.cpp index bd84ca0fab5333ac6cf77dd4dba6b9dd6fe9184e..8bce4f1835b98f7cacaabb6ad676921cc62a0fc6 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 bbd2ef0deebdf8d701c3dff3260f05c4b2fc8a18..7472eafc9f4e236d883d10ab400f01d21b712717 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