diff --git a/format/mpeg/mpeg_spu.go b/format/mpeg/mpeg_spu.go index deacaafc..a645e7a8 100644 --- a/format/mpeg/mpeg_spu.go +++ b/format/mpeg/mpeg_spu.go @@ -103,6 +103,9 @@ func spuDecode(d *decode.D, in interface{}) interface{} { d.FieldU16("size") dcsqtOffset := d.FieldU16("dcsqt_offset") + // to catch infinite loops + offsetSeen := map[uint64]struct{}{} + d.SeekAbs(int64(dcsqtOffset) * 8) d.FieldArray("dcsqt", func(d *decode.D) { lastDCSQ := false @@ -117,6 +120,11 @@ func spuDecode(d *decode.D, in interface{}) interface{} { return } + if _, ok := offsetSeen[offset]; ok { + d.Fatalf("dcsqt loop detected for %d", offset) + } + offsetSeen[offset] = struct{}{} + var pxdTFOffset int64 var pxdBFOffset int64 var width uint64