summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Lehtimäki <matti.lehtimaki@gmail.com>2014-08-23 09:59:54 +0200
committerMatti Lehtimäki <matti.lehtimaki@gmail.com>2014-08-23 09:59:54 +0200
commit55a4be45520177acb809b6b58f36a16bff3ab739 (patch)
tree3eead1e2958a7a84ceafce4a144b6504fb2c64c5
parentec36c62f4360daf9d39564e040ac4b181baf4316 (diff)
downloadvdr-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.c17
-rw-r--r--tools.c19
2 files changed, 27 insertions, 9 deletions
diff --git a/epgclone.c b/epgclone.c
index 4c7b28e..46397d1 100644
--- a/epgclone.c
+++ b/epgclone.c
@@ -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)
diff --git a/tools.c b/tools.c
index 0494166..843a29c 100644
--- a/tools.c
+++ b/tools.c
@@ -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);