diff options
author | Matti Lehtimäki <matti.lehtimaki@gmail.com> | 2014-08-23 09:59:54 +0200 |
---|---|---|
committer | Matti Lehtimäki <matti.lehtimaki@gmail.com> | 2014-08-23 09:59:54 +0200 |
commit | 55a4be45520177acb809b6b58f36a16bff3ab739 (patch) | |
tree | 3eead1e2958a7a84ceafce4a144b6504fb2c64c5 | |
parent | ec36c62f4360daf9d39564e040ac4b181baf4316 (diff) | |
download | vdr-plugin-epgfixer-55a4be45520177acb809b6b58f36a16bff3ab739.tar.gz vdr-plugin-epgfixer-55a4be45520177acb809b6b58f36a16bff3ab739.tar.bz2 |
Fix crash when cloning to a non-existent channel, thanks to Guy Martin.
Automatically disable the cloning which causes an error.
-rw-r--r-- | epgclone.c | 17 | ||||
-rw-r--r-- | tools.c | 19 |
2 files changed, 27 insertions, 9 deletions
@@ -48,11 +48,22 @@ void cEpgClone::CloneEvent(cEvent *Source, cEvent *Dest) { if (Source->Seen()) Dest->SetSeen(); tChannelID channelID; - if (dest_num) - channelID = Channels.GetByNumber(dest_num)->GetChannelID(); + if (dest_num) { + cChannel *dest_chan = Channels.GetByNumber(dest_num); + if (dest_chan) + channelID = Channels.GetByNumber(dest_num)->GetChannelID(); + else + channelID = tChannelID::InvalidID; + } else channelID = tChannelID::FromString(dest_str); - AddEvent(Dest, channelID); + if (channelID == tChannelID::InvalidID) { + enabled = false; + delete Dest; + error("Destination channel %s not found for cloning, disabling cloning!", (dest_num ? *itoa(dest_num) : dest_str)); + } + else + AddEvent(Dest, channelID); } bool cEpgClone::Apply(cEvent *Event) @@ -469,13 +469,20 @@ void cAddEventThread::Action(void) cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); Lock(); while (schedules && (e = list->First()) != NULL) { - cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); - if (schedule) { - schedule->AddEvent(e->GetEvent()); - EpgHandlers.SortSchedule(schedule); - EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); - list->Del(e); + tChannelID chanid = e->GetChannelID(); + cChannel *chan = Channels.GetByChannelID(chanid); + if (!chan) { + error("Destination channel %s not found for cloning!", *chanid.ToString()); } + else { + cSchedule *schedule = (cSchedule *)schedules->GetSchedule(chan, true); + if (schedule) { + schedule->AddEvent(e->GetEvent()); + EpgHandlers.SortSchedule(schedule); + EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); + } + } + list->Del(e); } Unlock(); cCondWait::SleepMs(10); |