Skip to content

Commit 4e231b4

Browse files
Timothy B. Terriberrytmatth
authored andcommitted
vorbis_psy: fix the half-octave bounds check in _vp_psy_init
Reported-by: Dutchman101 "<[email protected]>" Original commit message from the equivalent vorbis patch: > The existing code ensured that halfoc would not exceed P_BANDS-1, > but the interpolation used index P_BANDS (albeit with a weight > of 0) when this bound was actually hit. > Add an extra clamp on the integer index to avoid this. > Thanks to Paul Adenot for the report. See the original vorbis patch here: https://gitlab.xiph.org/xiph/vorbis/-/commit/315da9cc9d30484c802b2e2ea150df39e060e2b9.patch Signed-off-by: Tristan Matthews <[email protected]>
1 parent 5b58108 commit 4e231b4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

libspeex/vorbis_psy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ VorbisPsy *vorbis_psy_init(int rate, int n)
340340
if(halfoc<0)halfoc=0;
341341
if(halfoc>=P_BANDS-1)halfoc=P_BANDS-1;
342342
inthalfoc=(int)halfoc;
343+
/*If we hit the P_BANDS-1 clamp above, inthalfoc+1 will be out of bounds,
344+
even though it will have an interpolation weight of 0.
345+
Shift the interval so we don't read past the end of the array.*/
346+
if(inthalfoc>=P_BANDS-2)inthalfoc=P_BANDS-2;
343347
del=halfoc-inthalfoc;
344348

345349
p->noiseoffset[i]=

0 commit comments

Comments
 (0)