diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2015-08-29 19:21:35 +0100 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2015-08-29 19:21:35 +0100 |
commit | e924967fd5ec240cf97022f054cb02a0bc7101d9 (patch) | |
tree | a0a14f8c9b0710b43654cc960211856a229a93aa /libavcodec | |
parent | 902ac9ca74d5d39752f9cf42e9432d5a910e9650 (diff) | |
download | ffmpeg-e924967fd5ec240cf97022f054cb02a0bc7101d9.tar.gz |
aacenc_tns: fix out-of-bounds array access
Since the coefficients are stepped up to order + 1 it was possible
that it went over TNS_MAX_ORDER. Also just return in case the only
coefficient is less than the threshold.
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/aacenc_tns.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c index 0b22b6755e..a7433a8d19 100644 --- a/libavcodec/aacenc_tns.c +++ b/libavcodec/aacenc_tns.c @@ -97,6 +97,10 @@ static void process_tns_coeffs(TemporalNoiseShaping *tns, double *coef_raw, break; } } + order = av_clip(order, 0, TNS_MAX_ORDER - 1); + *order_p = order; + if (!order) + return; /* Step up procedure, convert to LPC coeffs */ out[0] = 1.0f; @@ -109,7 +113,6 @@ static void process_tns_coeffs(TemporalNoiseShaping *tns, double *coef_raw, } out[i] = lpc[i-1]; } - *order_p = order; memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float)); } |