Skip to content

Commit

Permalink
Decode: fix packet length
Browse files Browse the repository at this point in the history
Segments may vary in size before the final packet.
  • Loading branch information
mccoyst committed May 6, 2015
1 parent c024df7 commit a283027
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ func (d *Decoder) Decode() (Page, error) {
return Page{}, err
}

packetlen := mss*(nsegs-1) + int(segtbl[nsegs-1])
packetlen := 0
// This seems to contradict the spec, which says a segment with length < 255
// indicates the end of a packet. But hey, libogg puts out short non-final segments,
// so what can I do.
for _, l := range segtbl {
packetlen += int(l)
}

packet := d.buf[headsz+nsegs : headsz+nsegs+packetlen]
_, err = io.ReadFull(d.r, packet)
if err != nil {
Expand Down

0 comments on commit a283027

Please sign in to comment.