Prevent out of bounds indices accessing arrays Change-Id: Ic20b7314fc3a61738f2089d393f672d801037dda
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c index 2d7e5aa..5b62d81 100644 --- a/av1/encoder/rd.c +++ b/av1/encoder/rd.c
@@ -173,18 +173,20 @@ int sign_cost[CFL_JOINT_SIGNS]; av1_cost_tokens_from_cdf(sign_cost, fc->cfl_sign_cdf, NULL); for (int joint_sign = 0; joint_sign < CFL_JOINT_SIGNS; joint_sign++) { - const aom_cdf_prob *cdf_u = fc->cfl_alpha_cdf[CFL_CONTEXT_U(joint_sign)]; - const aom_cdf_prob *cdf_v = fc->cfl_alpha_cdf[CFL_CONTEXT_V(joint_sign)]; int *cost_u = x->cfl_cost[joint_sign][CFL_PRED_U]; int *cost_v = x->cfl_cost[joint_sign][CFL_PRED_V]; - if (CFL_SIGN_U(joint_sign) == CFL_SIGN_ZERO) + if (CFL_SIGN_U(joint_sign) == CFL_SIGN_ZERO) { memset(cost_u, 0, CFL_ALPHABET_SIZE * sizeof(*cost_u)); - else + } else { + const aom_cdf_prob *cdf_u = fc->cfl_alpha_cdf[CFL_CONTEXT_U(joint_sign)]; av1_cost_tokens_from_cdf(cost_u, cdf_u, NULL); - if (CFL_SIGN_V(joint_sign) == CFL_SIGN_ZERO) + } + if (CFL_SIGN_V(joint_sign) == CFL_SIGN_ZERO) { memset(cost_v, 0, CFL_ALPHABET_SIZE * sizeof(*cost_v)); - else + } else { + const aom_cdf_prob *cdf_v = fc->cfl_alpha_cdf[CFL_CONTEXT_V(joint_sign)]; av1_cost_tokens_from_cdf(cost_v, cdf_v, NULL); + } for (int u = 0; u < CFL_ALPHABET_SIZE; u++) cost_u[u] += sign_cost[joint_sign]; }