summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc_tns.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2015-08-29 19:21:35 +0100
committerRostislav Pehlivanov <atomnuker@gmail.com>2015-08-29 19:21:35 +0100
commite924967fd5ec240cf97022f054cb02a0bc7101d9 (patch)
treea0a14f8c9b0710b43654cc960211856a229a93aa /libavcodec/aacenc_tns.c
parent902ac9ca74d5d39752f9cf42e9432d5a910e9650 (diff)
downloadffmpeg-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/aacenc_tns.c')
-rw-r--r--libavcodec/aacenc_tns.c5
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));
}