[libbluray-devel] commit: Add protection against corrupt clpi files. (john )
git at videolan.org
git at videolan.org
Fri Dec 17 20:13:00 CET 2010
libbluray | branch: master | john <john at anonymous.org> | Fri Dec 17 11:09:53 2010 -0800| [07cd746a3bd0ce134231d79157d4e44811cd550a] | committer: john
Add protection against corrupt clpi files.
clpi_parse can return null when the clpi file is corrupt.
so check for NULL clip info before using it.
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=07cd746a3bd0ce134231d79157d4e44811cd550a
---
src/libbluray/bdnav/navigation.c | 33 ++++++++++++++++++++++++++++-----
1 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/libbluray/bdnav/navigation.c b/src/libbluray/bdnav/navigation.c
index 455bb29..19ae48e 100644
--- a/src/libbluray/bdnav/navigation.c
+++ b/src/libbluray/bdnav/navigation.c
@@ -280,6 +280,10 @@ uint8_t nav_lookup_aspect(NAV_CLIP *clip, int pid)
CLPI_PROG *progs;
int ii, jj;
+ if (clip->cl == NULL) {
+ return 0;
+ }
+
progs = clip->cl->program.progs;
for (ii = 0; ii < clip->cl->program.num_prog; ii++) {
CLPI_PROG_STREAM *ps = progs[ii].streams;
@@ -307,8 +311,12 @@ _fill_mark(NAV_TITLE *title, NAV_MARK *mark, int entry)
mark->mark_type = plm->mark_type;
mark->clip_ref = plm->play_item_ref;
clip = &title->clip_list.clip[mark->clip_ref];
- mark->clip_pkt = clpi_lookup_spn(clip->cl, plm->time, 1,
- title->pl->play_item[mark->clip_ref].clip[title->angle].stc_id);
+ if (clip->cl != NULL) {
+ mark->clip_pkt = clpi_lookup_spn(clip->cl, plm->time, 1,
+ title->pl->play_item[mark->clip_ref].clip[title->angle].stc_id);
+ } else {
+ mark->clip_pkt = clip->start_pkt;
+ }
mark->title_pkt = clip->title_pkt + mark->clip_pkt;
mark->clip_time = plm->time;
@@ -622,7 +630,11 @@ NAV_CLIP* nav_packet_search(NAV_TITLE *title, uint32_t pkt, uint32_t *clip_pkt,
*clip_pkt = clip->end_pkt;
} else {
clip = &title->clip_list.clip[ii];
- *clip_pkt = clpi_access_point(clip->cl, pkt - pos + clip->start_pkt, 0, 0, out_time);
+ if (clip->cl != NULL) {
+ *clip_pkt = clpi_access_point(clip->cl, pkt - pos + clip->start_pkt, 0, 0, out_time);
+ } else {
+ *clip_pkt = clip->start_pkt;
+ }
}
if(*out_time < clip->in_time)
*out_time = 0;
@@ -655,6 +667,9 @@ NAV_CLIP* nav_packet_search(NAV_TITLE *title, uint32_t pkt, uint32_t *clip_pkt,
// by the clip.
uint32_t nav_angle_change_search(NAV_CLIP *clip, uint32_t pkt, uint32_t *time)
{
+ if (clip->cl == NULL) {
+ return pkt;
+ }
return clpi_access_point(clip->cl, pkt, 1, 1, time);
}
@@ -680,8 +695,12 @@ NAV_CLIP* nav_time_search(NAV_TITLE *title, uint32_t tick, uint32_t *clip_pkt, u
*clip_pkt = clip->end_pkt;
} else {
clip = &title->clip_list.clip[ii];
- *clip_pkt = clpi_lookup_spn(clip->cl, tick - pos + pi->in_time, 1,
+ if (clip->cl != NULL) {
+ *clip_pkt = clpi_lookup_spn(clip->cl, tick - pos + pi->in_time, 1,
title->pl->play_item[clip->ref].clip[clip->angle].stc_id);
+ } else {
+ *clip_pkt = clip->start_pkt;
+ }
}
*out_pkt = clip->pos + *clip_pkt - clip->start_pkt;
return clip;
@@ -694,8 +713,12 @@ void nav_clip_time_search(NAV_CLIP *clip, uint32_t tick, uint32_t *clip_pkt, uin
if (tick >= clip->out_time) {
*clip_pkt = clip->end_pkt;
} else {
- *clip_pkt = clpi_lookup_spn(clip->cl, tick, 1,
+ if (clip->cl != NULL) {
+ *clip_pkt = clpi_lookup_spn(clip->cl, tick, 1,
clip->title->pl->play_item[clip->ref].clip[clip->angle].stc_id);
+ } else {
+ *clip_pkt = clip->start_pkt;
+ }
}
*out_pkt = clip->pos + *clip_pkt - clip->start_pkt;
}
More information about the libbluray-devel
mailing list