Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Commit

Permalink
frames: Bug fix: crash at *Frame.stereoProcessIntensityLong
Browse files Browse the repository at this point in the history
Fixes #24
  • Loading branch information
hajimehoshi committed Feb 7, 2018
1 parent 81bb838 commit 3c185f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions fuzzing_test.go
Expand Up @@ -90,6 +90,23 @@ func TestFuzzing(t *testing.T) {
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000",
// #24
"\xff\xfb0x000000\xf9000\x00\x030000" +
"000000000000\xf70000000" +
"\x900000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"0000000000000",
}
for _, input := range inputs {
b := &bytesReadCloser{bytes.NewReader([]byte(input))}
Expand Down
6 changes: 3 additions & 3 deletions internal/frame/frame.go
Expand Up @@ -297,8 +297,8 @@ var (
func (f *Frame) stereoProcessIntensityLong(gr int, sfb int) {
is_ratio_l := float32(0)
is_ratio_r := float32(0)
// Check that((is_pos[sfb]=scalefac) != 7) => no intensity stereo
if is_pos := f.mainData.ScalefacL[gr][0][sfb]; is_pos != 7 {
// Check that((is_pos[sfb]=scalefac) < 7) => no intensity stereo
if is_pos := f.mainData.ScalefacL[gr][0][sfb]; is_pos < 7 {
sfreq := f.header.SamplingFrequency() // Setup sampling freq index
sfb_start := consts.SfBandIndicesSet[sfreq].L[sfb]
sfb_stop := consts.SfBandIndicesSet[sfreq].L[sfb+1]
Expand All @@ -325,7 +325,7 @@ func (f *Frame) stereoProcessIntensityShort(gr int, sfb int) {
win_len := consts.SfBandIndicesSet[sfreq].S[sfb+1] - consts.SfBandIndicesSet[sfreq].S[sfb]
// The three windows within the band has different scalefactors
for win := 0; win < 3; win++ {
// Check that((is_pos[sfb]=scalefac) != 7) => no intensity stereo
// Check that((is_pos[sfb]=scalefac) < 7) => no intensity stereo
is_pos := f.mainData.ScalefacS[gr][0][sfb][win]
if is_pos < 7 {
sfb_start := consts.SfBandIndicesSet[sfreq].S[sfb]*3 + win_len*win
Expand Down

0 comments on commit 3c185f9

Please sign in to comment.