Index: source/lobby/XmppClient.cpp =================================================================== --- source/lobby/XmppClient.cpp +++ source/lobby/XmppClient.cpp @@ -1,4 +1,5 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. + * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -160,6 +163,7 @@ DbgXMPP("XmppClient destroyed"); delete m_registration; delete m_mucRoom; + delete m_sessionManager; // Workaround for memory leak in gloox 1.0/1.0.1 m_client->removePresenceExtension(gloox::ExtCaps); Index: source/lobby/glooxwrapper/glooxwrapper.h =================================================================== --- source/lobby/glooxwrapper/glooxwrapper.h +++ source/lobby/glooxwrapper/glooxwrapper.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -643,8 +643,6 @@ public: Jingle(const gloox::Jingle::Session::Jingle* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} - const PluginList plugins() const; - ICEUDP::Candidate getCandidate() const; }; Index: source/lobby/glooxwrapper/glooxwrapper.cpp =================================================================== --- source/lobby/glooxwrapper/glooxwrapper.cpp +++ source/lobby/glooxwrapper/glooxwrapper.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -284,7 +284,9 @@ virtual void handleSessionAction(gloox::Jingle::Action action, gloox::Jingle::Session* session, const gloox::Jingle::Session::Jingle* jingle) { - m_Wrapped->handleSessionAction(action, new glooxwrapper::Jingle::Session(session, false), new glooxwrapper::Jingle::Session::Jingle(jingle, false)); + glooxwrapper::Jingle::Session wrapped_session(session, false); + glooxwrapper::Jingle::Session::Jingle wrapped_jingle(jingle, false); + m_Wrapped->handleSessionAction(action, &wrapped_session, &wrapped_jingle); } virtual void handleSessionActionError(gloox::Jingle::Action UNUSED(action), gloox::Jingle::Session* UNUSED(session), const gloox::Error* UNUSED(error)) @@ -806,14 +808,6 @@ m_Owned = true; } -const glooxwrapper::Jingle::PluginList glooxwrapper::Jingle::Session::Jingle::plugins() const -{ - glooxwrapper::Jingle::PluginList pluginListWrapper; - for (const gloox::Jingle::Plugin* const& plugin : m_Wrapped->plugins()) - pluginListWrapper.push_back(new glooxwrapper::Jingle::Plugin(const_cast(plugin), false)); - return pluginListWrapper; -} - glooxwrapper::Jingle::ICEUDP::Candidate glooxwrapper::Jingle::Session::Jingle::getCandidate() const { const gloox::Jingle::Content* content = static_cast(m_Wrapped->plugins().front()); @@ -850,6 +844,7 @@ gloox::Jingle::PluginList* pluginList = new gloox::Jingle::PluginList(); pluginList->push_back(new gloox::Jingle::ICEUDP(/*local_pwd*/"", /*local_ufrag*/"", *candidateList)); + // Note that sessionInitiate assumes ownership of pluginList, so we do not leak memory here return m_Wrapped->sessionInitiate(new gloox::Jingle::Content(std::string("game-data"), *pluginList)); }