eitd/sectionsd.cpp: fix SIevent times.begin()-> access - times could be empty

This commit is contained in:
[CST] Focus
2012-05-09 17:33:37 +04:00
parent 1c89d21b41
commit 37a482d8e2

View File

@@ -362,7 +362,7 @@ xprintf("addEvent: current %016llx event %016llx running %d messaging_got_CN %d\
si->second->itemDescription = evt.itemDescription; si->second->itemDescription = evt.itemDescription;
si->second->item = evt.item; si->second->item = evt.item;
si->second->vps = evt.vps; si->second->vps = evt.vps;
if ((evt.getExtendedText().length() > 0) && if ((evt.getExtendedText().length() > 0) && !evt.times.empty() &&
(evt.times.begin()->startzeit < zeit + secondsExtendedTextCache)) (evt.times.begin()->startzeit < zeit + secondsExtendedTextCache))
si->second->setExtendedText("OFF",evt.getExtendedText().c_str()); si->second->setExtendedText("OFF",evt.getExtendedText().c_str());
if (evt.getText().length() > 0) if (evt.getText().length() > 0)
@@ -701,7 +701,7 @@ static const SIevent& findNextSIeventForServiceUniqueKey(const t_channel_id serv
return nullEvt; return nullEvt;
} }
// Sucht das naechste Event anhand unique key und Startzeit // Finds the next event based on unique key and start time
static const SIevent &findNextSIevent(const event_id_t uniqueKey, SItime &zeit) static const SIevent &findNextSIevent(const event_id_t uniqueKey, SItime &zeit)
{ {
MySIeventsOrderUniqueKey::iterator eFirst = mySIeventsOrderUniqueKey.find(uniqueKey); MySIeventsOrderUniqueKey::iterator eFirst = mySIeventsOrderUniqueKey.find(uniqueKey);
@@ -2304,7 +2304,7 @@ void sectionsd_getCurrentNextServiceKey(t_channel_id uniqueServiceKey, CSections
SItime zeitEvt1(0, 0); SItime zeitEvt1(0, 0);
if (!(flag & CSectionsdClient::epgflags::has_current)) { if (!(flag & CSectionsdClient::epgflags::has_current)) {
currentEvt = findActualSIeventForServiceUniqueKey(uniqueServiceKey, zeitEvt1, 0, &flag2); currentEvt = findActualSIeventForServiceUniqueKey(uniqueServiceKey, zeitEvt1, 0, &flag2);
} else { } else if(!currentEvt.times.empty()) {
zeitEvt1.startzeit = currentEvt.times.begin()->startzeit; zeitEvt1.startzeit = currentEvt.times.begin()->startzeit;
zeitEvt1.dauer = currentEvt.times.begin()->dauer; zeitEvt1.dauer = currentEvt.times.begin()->dauer;
} }
@@ -2338,9 +2338,10 @@ void sectionsd_getCurrentNextServiceKey(t_channel_id uniqueServiceKey, CSections
nextEvt = findNextSIeventForServiceUniqueKey(uniqueServiceKey, zeitEvt2); nextEvt = findNextSIeventForServiceUniqueKey(uniqueServiceKey, zeitEvt2);
} }
/* FIXME what this code should do ? why search channel id as event key ?? */
#if 0
if (nextEvt.service_id != 0) if (nextEvt.service_id != 0)
{ {
/* FIXME what this code should do ? why search channel id as event key ?? */
MySIeventsOrderUniqueKey::iterator eFirst = mySIeventsOrderUniqueKey.find(uniqueServiceKey); MySIeventsOrderUniqueKey::iterator eFirst = mySIeventsOrderUniqueKey.find(uniqueServiceKey);
if (eFirst != mySIeventsOrderUniqueKey.end()) if (eFirst != mySIeventsOrderUniqueKey.end())
@@ -2354,12 +2355,13 @@ void sectionsd_getCurrentNextServiceKey(t_channel_id uniqueServiceKey, CSections
{ {
time_t azeit = time(NULL); time_t azeit = time(NULL);
if (eFirst->second->times.begin()->startzeit < azeit && if (!eFirst->second->times.empty() && eFirst->second->times.begin()->startzeit < azeit &&
eFirst->second->uniqueKey() == nextEvt.uniqueKey() - 1) eFirst->second->uniqueKey() == nextEvt.uniqueKey() - 1)
flag |= CSectionsdClient::epgflags::has_no_current; flag |= CSectionsdClient::epgflags::has_no_current;
} }
} }
} }
#endif
} }
} }
if (nextEvt.service_id != 0) if (nextEvt.service_id != 0)
@@ -2397,10 +2399,16 @@ void sectionsd_getCurrentNextServiceKey(t_channel_id uniqueServiceKey, CSections
CSectionsdClient::sectionsdTime time_cur; CSectionsdClient::sectionsdTime time_cur;
CSectionsdClient::sectionsdTime time_nxt; CSectionsdClient::sectionsdTime time_nxt;
now = time(NULL); now = time(NULL);
time_cur.startzeit = time_cur.dauer = 0;
if(!currentEvt.times.empty()) {
time_cur.startzeit = currentEvt.times.begin()->startzeit; time_cur.startzeit = currentEvt.times.begin()->startzeit;
time_cur.dauer = currentEvt.times.begin()->dauer; time_cur.dauer = currentEvt.times.begin()->dauer;
}
time_nxt.startzeit = time_nxt.dauer = 0;
if(!nextEvt.times.empty()) {
time_nxt.startzeit = nextEvt.times.begin()->startzeit; time_nxt.startzeit = nextEvt.times.begin()->startzeit;
time_nxt.dauer = nextEvt.times.begin()->dauer; time_nxt.dauer = nextEvt.times.begin()->dauer;
}
/* for nvod events that have multiple times, find the one that matches the current time... */ /* for nvod events that have multiple times, find the one that matches the current time... */
if (currentEvt.times.size() > 1) { if (currentEvt.times.size() > 1) {
for (SItimes::iterator t = currentEvt.times.begin(); t != currentEvt.times.end(); ++t) { for (SItimes::iterator t = currentEvt.times.begin(); t != currentEvt.times.end(); ++t) {
@@ -2520,8 +2528,10 @@ bool sectionsd_getActualEPGServiceKey(const t_channel_id uniqueServiceKey, CEPGD
if (uniqueServiceKey == messaging_current_servicekey) { if (uniqueServiceKey == messaging_current_servicekey) {
if (myCurrentEvent) { if (myCurrentEvent) {
evt = *myCurrentEvent; evt = *myCurrentEvent;
if(!evt.times.empty()) {
zeit.startzeit = evt.times.begin()->startzeit; zeit.startzeit = evt.times.begin()->startzeit;
zeit.dauer = evt.times.begin()->dauer; zeit.dauer = evt.times.begin()->dauer;
}
if (evt.times.size() > 1) { if (evt.times.size() > 1) {
time_t now = time(NULL); time_t now = time(NULL);
for (SItimes::iterator t = evt.times.begin(); t != evt.times.end(); ++t) { for (SItimes::iterator t = evt.times.begin(); t != evt.times.end(); ++t) {