Skip to content

Commit

Permalink
h265: fix panic when marshaling SPS
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Aug 1, 2024
1 parent a94f00b commit 0f439fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/codecs/h265/sps.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,11 @@ func (s *SPS) Unmarshal(buf []byte) error {
return err
}

// this prevents a panic in Marshal()
if s.ChromaFormatIdc > 3 {
return fmt.Errorf("invalid chroma_format_idc")
}

if s.ChromaFormatIdc == 3 {
s.SeparateColourPlaneFlag, err = bits.ReadFlag(buf, &pos)
if err != nil {
Expand Down

0 comments on commit 0f439fd

Please sign in to comment.