av1_first_pass: fix non-zero offset of null ptr check num_planes before incrementing x->plane[].src.buf this fixes four non-zero offset of a null pointer warnings under clang -fsanitize=undefined: firstpass.c:947: runtime error: applying non-zero offset 8 to null pointer firstpass.c:948: runtime error: applying non-zero offset 8 to null pointer firstpass.c:955: runtime error: applying non-zero offset to non-null pointer 0x0000000000b0 produced null pointer firstpass.c:957: runtime error: applying non-zero offset to non-null pointer 0x0000000000b0 produced null pointer Analogous to https://aomedia-review.googlesource.com/c/aom/+/162443. Change-Id: I7cf8f8b3dcd6442d2e192de98333eed9d5b34d6d
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c index 113c068..4ec7997 100644 --- a/av1/encoder/firstpass.c +++ b/av1/encoder/firstpass.c
@@ -944,18 +944,22 @@ // Adjust to the next column of MBs. x->plane[0].src.buf += 16; - x->plane[1].src.buf += uv_mb_height; - x->plane[2].src.buf += uv_mb_height; + if (num_planes > 1) { + x->plane[1].src.buf += uv_mb_height; + x->plane[2].src.buf += uv_mb_height; + } recon_yoffset += 16; recon_uvoffset += uv_mb_height; } // Adjust to the next row of MBs. x->plane[0].src.buf += 16 * x->plane[0].src.stride - 16 * cm->mb_cols; - x->plane[1].src.buf += - uv_mb_height * x->plane[1].src.stride - uv_mb_height * cm->mb_cols; - x->plane[2].src.buf += - uv_mb_height * x->plane[1].src.stride - uv_mb_height * cm->mb_cols; + if (num_planes > 1) { + x->plane[1].src.buf += + uv_mb_height * x->plane[1].src.stride - uv_mb_height * cm->mb_cols; + x->plane[2].src.buf += + uv_mb_height * x->plane[1].src.stride - uv_mb_height * cm->mb_cols; + } aom_clear_system_state(); }