OSDN Git Service

dvdnav: fix crash that occurs when a PGC has no programs
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 29 May 2009 00:01:27 +0000 (00:01 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 29 May 2009 00:01:27 +0000 (00:01 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@2457 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/dvdnav.c

index 515de1e..589c916 100644 (file)
@@ -251,6 +251,12 @@ PttDuration(ifo_handle_t *ifo, int ttn, int pttn, int *blocks, int *last_pgcn)
             hb_error( "scan: pgc not valid, skipping" );
             break;
         }
+        if (pgn > pgc->nr_of_programs)
+        {
+            pgn = 1;
+            continue;
+        }
+
         duration += 90LL * dvdtime2msec( &pgc->playback_time );
 
         cell_start = pgc->program_map[pgn-1] - 1;
@@ -419,6 +425,11 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t )
     pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc;
 
     hb_log("pgc_id: %d, pgn: %d: pgc: 0x%x", pgcn, pgn, pgc);
+    if (pgn > pgc->nr_of_programs)
+    {
+        hb_error( "invalid PGN %d for title %d, skipping", pgn, t );
+        goto fail;
+    }
 
     /* Title start */
     title->cell_start = pgc->program_map[pgn-1] - 1;