Skip to content

Commit 6b550fc

Browse files
committed
Fix a segfault in the EIT cache
(cherry picked from commit 2e8c5f8)
1 parent 56acf7c commit 6b550fc

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

mythtv/libs/libmythtv/eitcache.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,12 @@ event_map_t * EITCache::LoadChannel(uint chanid)
249249
return eventMap;
250250
}
251251

252-
void EITCache::WriteChannelToDB(QStringList &value_clauses, uint chanid)
252+
bool EITCache::WriteChannelToDB(QStringList &value_clauses, uint chanid)
253253
{
254254
event_map_t * eventMap = channelMap[chanid];
255255

256256
if (!eventMap)
257-
{
258-
channelMap.remove(chanid);
259-
return;
260-
}
257+
return false;
261258

262259
uint size = eventMap->size();
263260
uint updated = 0;
@@ -294,6 +291,8 @@ void EITCache::WriteChannelToDB(QStringList &value_clauses, uint chanid)
294291
"for channel %3 from cache.")
295292
.arg(removed).arg(size).arg(chanid));
296293
pruneCnt += removed;
294+
295+
return true;
297296
}
298297

299298
void EITCache::WriteToDB(void)
@@ -304,8 +303,10 @@ void EITCache::WriteToDB(void)
304303
key_map_t::iterator it = channelMap.begin();
305304
while (it != channelMap.end())
306305
{
307-
WriteChannelToDB(value_clauses, it.key());
308-
++it;
306+
if (!WriteChannelToDB(value_clauses, it.key()))
307+
it = channelMap.erase(it);
308+
else
309+
++it;
309310
}
310311

311312
if(value_clauses.isEmpty())

mythtv/libs/libmythtv/eitcache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class EITCache
3636

3737
private:
3838
event_map_t * LoadChannel(uint chanid);
39-
void WriteChannelToDB(QStringList &value_clauses, uint chanid);
39+
bool WriteChannelToDB(QStringList &value_clauses, uint chanid);
4040

4141
// event key cache
4242
key_map_t channelMap;

0 commit comments

Comments
 (0)