diff --git a/pkg/aac/rtp.go b/pkg/aac/rtp.go index a59a0d67..b5ae4a10 100644 --- a/pkg/aac/rtp.go +++ b/pkg/aac/rtp.go @@ -28,9 +28,13 @@ func RTPDepay(handler core.HandlerFunc) core.HandlerFunc { headers := packet.Payload[2 : 2+headersSize] units := packet.Payload[2+headersSize:] - for len(headers) > 0 { + for len(headers) >= 2 { unitSize := binary.BigEndian.Uint16(headers) >> 3 + if len(units) < int(unitSize) { + return + } + unit := units[:unitSize] headers = headers[2:]