Skip to content
This repository
Browse code

Merge pull request #2420 from Montellese/rssmanager_locks

fix possible access violation in CRssManager::Clear() during shutdown
  • Loading branch information...
commit 482797ff7284b63f8c0ba2e0500ad709340a677c 2 parents 3d13a60 + a9cf850
Sascha Montellese authored March 15, 2013
4  xbmc/settings/Settings.cpp
@@ -141,9 +141,7 @@ void CSettings::Initialize()
141 141
 }
142 142
 
143 143
 CSettings::~CSettings(void)
144  
-{
145  
-  Clear();
146  
-}
  144
+{ }
147 145
 
148 146
 
149 147
 void CSettings::Save() const
6  xbmc/utils/RssManager.cpp
@@ -21,6 +21,7 @@
21 21
 #include "RssManager.h"
22 22
 #include "filesystem/File.h"
23 23
 #include "settings/Settings.h"
  24
+#include "threads/SingleLock.h"
24 25
 #include "utils/log.h"
25 26
 #include "utils/RssReader.h"
26 27
 #include "utils/StringUtils.h"
@@ -36,7 +37,6 @@ CRssManager::CRssManager()
36 37
 CRssManager::~CRssManager()
37 38
 {
38 39
   Stop();
39  
-  Clear();
40 40
 }
41 41
 
42 42
 CRssManager& CRssManager::Get()
@@ -52,6 +52,7 @@ void CRssManager::Start()
52 52
 
53 53
 void CRssManager::Stop()
54 54
 {
  55
+  CSingleLock lock(m_critical);
55 56
   m_bActive = false;
56 57
   for (unsigned int i = 0; i < m_readers.size(); i++)
57 58
   {
@@ -63,6 +64,7 @@ void CRssManager::Stop()
63 64
 
64 65
 bool CRssManager::Load()
65 66
 {
  67
+  CSingleLock lock(m_critical);
66 68
   string rssXML = g_settings.GetUserDataItem("RssFeeds.xml");
67 69
   if (!CFile::Exists(rssXML))
68 70
     return false;
@@ -134,12 +136,14 @@ bool CRssManager::Reload()
134 136
 
135 137
 void CRssManager::Clear()
136 138
 {
  139
+  CSingleLock lock(m_critical);
137 140
   m_mapRssUrls.clear();
138 141
 }
139 142
 
140 143
 // returns true if the reader doesn't need creating, false otherwise
141 144
 bool CRssManager::GetReader(int controlID, int windowID, IRssObserver* observer, CRssReader *&reader)
142 145
 {
  146
+  CSingleLock lock(m_critical);
143 147
   // check to see if we've already created this reader
144 148
   for (unsigned int i = 0; i < m_readers.size(); i++)
145 149
   {
3  xbmc/utils/RssManager.h
@@ -23,6 +23,8 @@
23 23
 #include <vector>
24 24
 #include <string>
25 25
 
  26
+#include "threads/CriticalSection.h"
  27
+
26 28
 class CRssReader;
27 29
 class IRssObserver;
28 30
 
@@ -66,4 +68,5 @@ class CRssManager
66 68
   std::vector<READERCONTROL> m_readers;
67 69
   RssUrls m_mapRssUrls;
68 70
   bool m_bActive;
  71
+  CCriticalSection m_critical;
69 72
 };

0 notes on commit 482797f

Please sign in to comment.
Something went wrong with that request. Please try again.