From bc0240298ba4d6b2838ebbdf5308c31499ff5f6b Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Thu, 23 May 2013 11:29:21 +0100 Subject: [PATCH] Initialise MythCoreContextPrivate::pluginmanager to NULL and add guards against leaks if SetPluginManager() is called twice --- mythtv/libs/libmythbase/mythcorecontext.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mythtv/libs/libmythbase/mythcorecontext.cpp b/mythtv/libs/libmythbase/mythcorecontext.cpp index c98414c91d4..b96204ba239 100644 --- a/mythtv/libs/libmythbase/mythcorecontext.cpp +++ b/mythtv/libs/libmythbase/mythcorecontext.cpp @@ -110,7 +110,8 @@ MythCoreContextPrivate::MythCoreContextPrivate(MythCoreContext *lparent, m_UIThread(QThread::currentThread()), m_locale(NULL), m_scheduler(NULL), - m_blockingClient(false) + m_blockingClient(false), + pluginmanager(NULL) { MThread::ThreadSetup("CoreContext"); srandom(MythDate::current().toTime_t() ^ QTime::currentTime().msec()); @@ -1469,6 +1470,15 @@ bool MythCoreContext::TestPluginVersion(const QString &name, void MythCoreContext::SetPluginManager(MythPluginManager *pmanager) { + if (d->pluginmanager == pmanager) + return; + + if (d->pluginmanager) + { + delete d->pluginmanager; + d->pluginmanager = NULL; + } + d->pluginmanager = pmanager; }