diff --git a/lib/psy.c b/lib/psy.c index 036b094aa763b3c8773386c17f548f70dfd1bc58..96213c42495485c3c96055558e1c52ad5f811c98 100644 --- a/lib/psy.c +++ b/lib/psy.c @@ -339,6 +339,10 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, if(halfoc<0)halfoc=0; if(halfoc>=P_BANDS-1)halfoc=P_BANDS-1; inthalfoc=(int)halfoc; + /*If we hit the P_BANDS-1 clamp above, inthalfoc+1 will be out of bounds, + even though it will have an interpolation weight of 0. + Shift the interval so we don't read past the end of the array.*/ + if(inthalfoc>=P_BANDS-2)inthalfoc=P_BANDS-2; del=halfoc-inthalfoc; for(j=0;j<P_NOISECURVES;j++)