Add protection around use of broadcast->episode-> as the episode is not always set (currenly opentv has limitations that cause this to happen).

This commit is contained in:
Adam Sutton 2012-06-20 10:21:03 +01:00
parent 173b6d12d7
commit f8344bc395
3 changed files with 27 additions and 21 deletions

View file

@ -182,7 +182,7 @@ dvr_make_title(char *output, size_t outlen, dvr_entry_t *de)
}
if(cfg->dvr_flags & DVR_EPISODE_IN_TITLE) {
if(de->de_bcast)
if(de->de_bcast && de->de_bcast->episode)
epg_episode_number_format(de->de_bcast->episode,
output + strlen(output),
outlen - strlen(output),
@ -354,7 +354,7 @@ dvr_entry_create_by_event(const char *config_name,
const char *creator,
dvr_autorec_entry_t *dae, dvr_prio_t pri)
{
if(!e->channel || !e->episode->title)
if(!e->channel || !e->episode || !e->episode->title)
return NULL;
return _dvr_entry_create(config_name, e,
@ -635,7 +635,8 @@ static dvr_entry_t *_dvr_entry_update
int start, stop;
if (e) {
title = e->episode->title;
if (e->episode)
title = e->episode->title;
start = e->start;
stop = e->stop;
} else {
@ -661,7 +662,8 @@ static dvr_entry_t *_dvr_entry_update
}
if (e) {
if (e->episode->genre_cnt && e->episode->genre_cnt != de->de_content_type) {
if (e->episode &&
e->episode->genre_cnt && e->episode->genre_cnt != de->de_content_type) {
de->de_content_type = e->episode->genre[0];
save = 1;
}
@ -710,7 +712,7 @@ dvr_event_replaced(epg_broadcast_t *e, epg_broadcast_t *new_e)
ude = dvr_entry_find_by_event_fuzzy(new_e);
if (ude == NULL && de->de_sched_state == DVR_SCHEDULED)
dvr_entry_cancel(de);
else if(new_e->episode->title != NULL)
else if(new_e->episode && new_e->episode->title)
_dvr_entry_update(de, new_e, NULL, 0, 0);
}
}
@ -818,7 +820,7 @@ dvr_entry_find_by_event_fuzzy(epg_broadcast_t *e)
{
dvr_entry_t *de;
if (e->episode->title == NULL)
if (!e->episode || !e->episode->title)
return NULL;
LIST_FOREACH(de, &e->channel->ch_dvrs, de_channel_link)

View file

@ -761,16 +761,18 @@ htsp_build_event(epg_broadcast_t *e)
htsmsg_add_u32(out, "channelId", e->channel->ch_id);
htsmsg_add_u32(out, "start", e->start);
htsmsg_add_u32(out, "stop", e->stop);
if(e->episode->title != NULL)
htsmsg_add_str(out, "title", e->episode->title);
if(e->episode->description != NULL)
htsmsg_add_str(out, "description", e->episode->description);
else if(e->episode->summary != NULL)
htsmsg_add_str(out, "description", e->episode->summary);
if (e->episode) {
if(e->episode->title != NULL)
htsmsg_add_str(out, "title", e->episode->title);
if(e->episode->description != NULL)
htsmsg_add_str(out, "description", e->episode->description);
else if(e->episode->summary != NULL)
htsmsg_add_str(out, "description", e->episode->summary);
// TODO: only supports one entry!
if(e->episode->genre_cnt)
htsmsg_add_u32(out, "contentType", e->episode->genre[0]);
// TODO: only supports one entry!
if(e->episode->genre_cnt)
htsmsg_add_u32(out, "contentType", e->episode->genre[0]);
}
if((de = dvr_entry_find_by_event(e)) != NULL) {
htsmsg_add_u32(out, "dvrId", de->de_id);

View file

@ -128,7 +128,7 @@ page_simple(http_connection_t *hc,
"%02d:%02d-%02d:%02d&nbsp;%s%s%s</a><br>",
e->id,
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min,
e->episode->title,
e->episode ? e->episode->title : "",
rstatus ? "&nbsp;" : "", rstatus ?: "");
}
}
@ -228,7 +228,7 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque)
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min);
htsbuf_qprintf(hq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
e->channel->ch_name, e->episode->title);
e->channel->ch_name, e->episode ? e->episode->title : "");
dvr_status = de != NULL ? de->de_sched_state : DVR_NOSTATE;
@ -260,10 +260,12 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque)
}
htsbuf_qprintf(hq, "</form>");
if ( e->episode->description )
htsbuf_qprintf(hq, "%s", e->episode->description);
else if ( e->episode->summary )
htsbuf_qprintf(hq, "%s", e->episode->summary);
if (e->episode) {
if ( e->episode->description )
htsbuf_qprintf(hq, "%s", e->episode->description);
else if ( e->episode->summary )
htsbuf_qprintf(hq, "%s", e->episode->summary);
}
pthread_mutex_unlock(&global_lock);