diff options
author | Memphiz <memphis@machzwo.de> | 2014-05-12 22:37:34 +0200 |
---|---|---|
committer | Jonathan Marshall <jmarshall@xbmc.org> | 2014-05-18 11:22:47 +1200 |
commit | deb6e97722b9850bba0fac4d2aab8e008981e8ce (patch) | |
tree | f1b57296899202e27c31fe5756ec162d150ccaf4 | |
parent | b876643f64a3c51c9dcb4c7e90eee15a46505c88 (diff) |
Merge pull request #4695 from Memphiz/badaccess
[airplay] - fix possible bad access as reported in
-rw-r--r-- | xbmc/network/AirPlayServer.cpp | 15 | ||||
-rw-r--r-- | xbmc/network/AirPlayServer.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/xbmc/network/AirPlayServer.cpp b/xbmc/network/AirPlayServer.cpp index 127a765985..8040d9b0d1 100644 --- a/xbmc/network/AirPlayServer.cpp +++ b/xbmc/network/AirPlayServer.cpp @@ -63,6 +63,7 @@ using namespace ANNOUNCEMENT; #define AIRPLAY_STATUS_NOT_IMPLEMENTED 501 #define AIRPLAY_STATUS_NO_RESPONSE_NEEDED 1000 +CCriticalSection CAirPlayServer::ServerInstanceLock; CAirPlayServer *CAirPlayServer::ServerInstance = NULL; int CAirPlayServer::m_isPlaying = 0; @@ -156,6 +157,8 @@ const char *eventStrings[] = {"playing", "paused", "loading", "stopped"}; void CAirPlayServer::Announce(AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data) { + CSingleLock lock(ServerInstanceLock); + if ( (flag & Player) && strcmp(sender, "xbmc") == 0 && ServerInstance) { if (strcmp(message, "OnStop") == 0) @@ -184,6 +187,8 @@ bool CAirPlayServer::StartServer(int port, bool nonlocal) { StopServer(true); + CSingleLock lock(ServerInstanceLock); + ServerInstance = new CAirPlayServer(port, nonlocal); if (ServerInstance->Initialize()) { @@ -196,6 +201,7 @@ bool CAirPlayServer::StartServer(int port, bool nonlocal) bool CAirPlayServer::SetCredentials(bool usePassword, const CStdString& password) { + CSingleLock lock(ServerInstanceLock); bool ret = false; if (ServerInstance) @@ -214,6 +220,7 @@ bool CAirPlayServer::SetInternalCredentials(bool usePassword, const CStdString& void CAirPlayServer::StopServer(bool bWait) { + CSingleLock lock(ServerInstanceLock); if (ServerInstance) { ServerInstance->StopThread(bWait); @@ -694,13 +701,17 @@ bool CAirPlayServer::CTCPClient::checkAuthorization(const CStdString& authStr, void CAirPlayServer::backupVolume() { - if (ServerInstance->m_origVolume == -1) + CSingleLock lock(ServerInstanceLock); + + if (ServerInstance && ServerInstance->m_origVolume == -1) ServerInstance->m_origVolume = (int)g_application.GetVolume(); } void CAirPlayServer::restoreVolume() { - if (ServerInstance->m_origVolume != -1 && CSettings::Get().GetBool("services.airplayvolumecontrol")) + CSingleLock lock(ServerInstanceLock); + + if (ServerInstance && ServerInstance->m_origVolume != -1 && CSettings::Get().GetBool("services.airplayvolumecontrol")) { g_application.SetVolume((float)ServerInstance->m_origVolume); ServerInstance->m_origVolume = -1; diff --git a/xbmc/network/AirPlayServer.h b/xbmc/network/AirPlayServer.h index 4c486fbff8..27c7f40b2d 100644 --- a/xbmc/network/AirPlayServer.h +++ b/xbmc/network/AirPlayServer.h @@ -112,6 +112,7 @@ private: CStdString m_password; int m_origVolume; + static CCriticalSection ServerInstanceLock; static CAirPlayServer *ServerInstance; }; |