Commit e924967f authored by Rostislav Pehlivanov's avatar Rostislav Pehlivanov

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: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
parent 902ac9ca
...@@ -97,6 +97,10 @@ static void process_tns_coeffs(TemporalNoiseShaping *tns, double *coef_raw, ...@@ -97,6 +97,10 @@ static void process_tns_coeffs(TemporalNoiseShaping *tns, double *coef_raw,
break; break;
} }
} }
order = av_clip(order, 0, TNS_MAX_ORDER - 1);
*order_p = order;
if (!order)
return;
/* Step up procedure, convert to LPC coeffs */ /* Step up procedure, convert to LPC coeffs */
out[0] = 1.0f; out[0] = 1.0f;
...@@ -109,7 +113,6 @@ static void process_tns_coeffs(TemporalNoiseShaping *tns, double *coef_raw, ...@@ -109,7 +113,6 @@ static void process_tns_coeffs(TemporalNoiseShaping *tns, double *coef_raw,
} }
out[i] = lpc[i-1]; out[i] = lpc[i-1];
} }
*order_p = order;
memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float)); memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment