Avoid out of bound read BLOCK_Z_TOKEN is defined "255", this commit change the order of operations to avoid read av1_extra_bits[255]. av1_extra_bits is defined with size of 12. Change-Id: I59c35136bb064391139579bce591d1963e722611
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 57ce7e2..cc6c0e8 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -856,13 +856,13 @@ while (p < stop && p->token != EOSB_TOKEN) { const int token = p->token; - const av1_extra_bit *const extra_bits = &av1_extra_bits[token]; - if (token == BLOCK_Z_TOKEN) { aom_write_symbol(w, 0, *p->head_cdf, HEAD_TOKENS + 1); p++; continue; } + + const av1_extra_bit *const extra_bits = &av1_extra_bits[token]; if (p->eob_val == LAST_EOB) { // Just code a flag indicating whether the value is >1 or 1. aom_write_bit(w, token != ONE_TOKEN);