media/libspeex_resampler/set-rate-overflow-no-return.patch
author Tooru Fujisawa <arai_a@mac.com>
Mon, 28 Sep 2020 17:14:34 +0000
changeset 550593 b3ea886b0ae7c2f056fead164116774dab00239b
parent 347149 c8df499e005abc1438c394dfa72257e369097d7d
permissions -rw-r--r--
Bug 1662273 - Use stencil XDR in incremental encoding and off-thread single script decoding. r=tcampbell Differential Revision: https://phabricator.services.mozilla.com/D91437

diff --git a/media/libspeex_resampler/src/resample.c b/media/libspeex_resampler/src/resample.c
--- a/media/libspeex_resampler/src/resample.c
+++ b/media/libspeex_resampler/src/resample.c
@@ -1141,18 +1141,19 @@ EXPORT int speex_resampler_set_rate_frac
 
    st->num_rate /= fact;
    st->den_rate /= fact;
 
    if (old_den > 0)
    {
       for (i=0;i<st->nb_channels;i++)
       {
-         if (_muldiv(&st->samp_frac_num[i],st->samp_frac_num[i],st->den_rate,old_den) != RESAMPLER_ERR_SUCCESS)
-            return RESAMPLER_ERR_OVERFLOW;
+         if (_muldiv(&st->samp_frac_num[i],st->samp_frac_num[i],st->den_rate,old_den) != RESAMPLER_ERR_SUCCESS) {
+           st->samp_frac_num[i] = st->den_rate-1;
+         }
          /* Safety net */
          if (st->samp_frac_num[i] >= st->den_rate)
             st->samp_frac_num[i] = st->den_rate-1;
       }
    }
 
    if (st->initialised)
       return update_filter(st);