aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/aacpsy.c
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-04-16 20:04:54 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-16 20:28:55 +0200
commite224aa41917454e7b5c23d9f2541425743ce595a (patch)
tree6f575b3e48401cb6762d227871f07c189086fc6c /libavcodec/aacpsy.c
parent0be54ad280cf114c02306b7063147e8379f8ed1e (diff)
downloadffmpeg-e224aa41917454e7b5c23d9f2541425743ce595a.tar.gz
aacpsy: avoid psy_band->threshold becoming NaN
If band->thr is 0.0f, the division is undefined, making norm_fac not a number or infinity, which causes psy_band->threshold to become NaN. This is passed on to other variables until it finally reaches sce->sf_idx and is converted to an integer (-2147483648). This causes a segmentation fault when it is used as array index. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Reviewed-by: Claudio Freire <klaussfreire@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/aacpsy.c')
-rw-r--r--libavcodec/aacpsy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index d1e65f6607..7205ee3bdb 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -727,7 +727,10 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
if (active_lines > 0.0f)
band->thr = calc_reduced_thr_3gpp(band, coeffs[g].min_snr, reduction);
pe += calc_pe_3gpp(band);
- band->norm_fac = band->active_lines / band->thr;
+ if (band->thr > 0.0f)
+ band->norm_fac = band->active_lines / band->thr;
+ else
+ band->norm_fac = 0.0f;
norm_fac += band->norm_fac;
}
}