Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

Commit 1b6e43a

Browse files
author
Jason Crawford
committed
Fix for buffer overflow
1 parent 1d8cab3 commit 1b6e43a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mixing/mixer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,20 @@ func (m *Mixer) FlattenTo(resultBuffers [][]byte, panmixer PanMixer, samplesLen
6868
data := m.NewMixBuffer(samplesLen)
6969
for _, rdata := range row {
7070
pos := 0
71+
maxLen := 0
7172
for _, cdata := range rdata {
7273
if cdata.Flush != nil {
7374
cdata.Flush()
7475
}
76+
if maxLen < cdata.SamplesLen {
77+
maxLen = cdata.SamplesLen
78+
}
7579
if len(cdata.Data) > 0 {
7680
volMtx := cdata.Volume.Apply(panmixer.GetMixingMatrix(cdata.Pan)...)
7781
data.Add(pos, cdata.Data, volMtx)
7882
}
79-
pos += cdata.SamplesLen
8083
}
84+
pos += maxLen
8185
}
8286
data.ToRenderDataWithBufs(resultBuffers, samplesLen, m.BitsPerSample, mixerVolume)
8387
}

0 commit comments

Comments
 (0)