1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/lpc: Avoid floating point division by 0

Fixes: Ticket7996
Fixes: CVE-2020-20445

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-05-28 20:31:19 +02:00
parent 223b5e8ac9
commit 38d18fb578
2 changed files with 3 additions and 3 deletions

View File

@ -189,7 +189,7 @@ double ff_lpc_calc_ref_coefs_f(LPCContext *s, const float *samples, int len,
compute_ref_coefs(autoc, order, ref, error);
for (i = 0; i < order; i++)
avg_err = (avg_err + error[i])/2.0f;
return signal/avg_err;
return avg_err ? signal/avg_err : NAN;
}
/**

View File

@ -143,7 +143,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
gen0[i] = gen1[i] = autoc[i + 1];
err = autoc[0];
ref[0] = -gen1[0] / err;
ref[0] = -gen1[0] / ((USE_FIXED || err) ? err : 1);
err += gen1[0] * ref[0];
if (error)
error[0] = err;
@ -152,7 +152,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
gen1[j] = gen1[j + 1] + ref[i - 1] * gen0[j];
gen0[j] = gen1[j + 1] * ref[i - 1] + gen0[j];
}
ref[i] = -gen1[0] / err;
ref[i] = -gen1[0] / ((USE_FIXED || err) ? err : 1);
err += gen1[0] * ref[i];
if (error)
error[i] = err;