From 41d12fb8f7a026281e2b0d99780db9bd7166b849 Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk@fabiankeil.de>
Date: Sat, 7 Jul 2012 22:23:47 +0200
Subject: [PATCH 2/3] Let dvdnav_describe_title_chapters() ignore parts where
 the pgc_start_byte is above the last_byte

This is a heuristic to prevent segfaults when
ifo->vts_pgcit->pgci_srp[ptt[i].pgcn-1].pgc is invalid
but non-NULL.
---
 src/searching.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/searching.c b/src/searching.c
index 3bdecab..96c5c7f 100644
--- a/src/searching.c
+++ b/src/searching.c
@@ -616,6 +616,10 @@ uint32_t dvdnav_describe_title_chapters(dvdnav_t *this, int32_t title, uint64_t
   length = 0;
   for(i=0; i<parts; i++) {
     uint32_t cellnr, endcellnr;
+    if (ifo->vts_pgcit->pgci_srp[ptt[i].pgcn-1].pgc_start_byte >= ifo->vts_pgcit->last_byte) {
+      printerr("PGC start out of bounds");
+      continue;
+    }
     pgc = ifo->vts_pgcit->pgci_srp[ptt[i].pgcn-1].pgc;
     if (pgc == NULL) {
       printerr("PGC missing.");
-- 
1.7.10.3

