Fix static analysis warnings With this change the number of warnings of shallow analysis is 0 and of deep analysis is 9. 5 of those 9 are in third_party and the other 4 are due to pointer conversion Change-Id: Ibd94f867f429024a7b4e2dbce05223a263994a24
diff --git a/aom_dsp/noise_model.c b/aom_dsp/noise_model.c index 7e6a833..528efd9 100644 --- a/aom_dsp/noise_model.c +++ b/aom_dsp/noise_model.c
@@ -214,6 +214,7 @@ int aom_noise_strength_lut_init(aom_noise_strength_lut_t *lut, int num_points) { if (!lut) return 0; + lut->num_points = 0; lut->points = (double(*)[2])aom_malloc(num_points * sizeof(*lut->points)); if (!lut->points) return 0; lut->num_points = num_points;
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h index 8a069d8..e6c30c6 100644 --- a/av1/common/onyxc_int.h +++ b/av1/common/onyxc_int.h
@@ -927,6 +927,8 @@ static INLINE BLOCK_SIZE scale_chroma_bsize(BLOCK_SIZE bsize, int subsampling_x, int subsampling_y) { + assert(subsampling_x >= 0 && subsampling_x < 2); + assert(subsampling_y >= 0 && subsampling_y < 2); BLOCK_SIZE bs = bsize; switch (bsize) { case BLOCK_4X4:
diff --git a/av1/common/scale.h b/av1/common/scale.h index 748e958..16b40bd 100644 --- a/av1/common/scale.h +++ b/av1/common/scale.h
@@ -45,11 +45,13 @@ int other_h, int this_w, int this_h); static INLINE int av1_is_valid_scale(const struct scale_factors *sf) { + assert(sf != NULL); return sf->x_scale_fp != REF_INVALID_SCALE && sf->y_scale_fp != REF_INVALID_SCALE; } static INLINE int av1_is_scaled(const struct scale_factors *sf) { + assert(sf != NULL); return av1_is_valid_scale(sf) && (sf->x_scale_fp != REF_NO_SCALE || sf->y_scale_fp != REF_NO_SCALE); }
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 7849a5c..d03601f 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c
@@ -1779,7 +1779,11 @@ partition = get_partition(cm, mi_row, mi_col, bsize); } subsize = get_partition_subsize(bsize, partition); - + if (subsize == BLOCK_INVALID) { + aom_internal_error(xd->error_info, AOM_CODEC_CORRUPT_FRAME, + "Partition is invalid for block size %dx%d", + block_size_wide[bsize], block_size_high[bsize]); + } // Check the bitstream is conformant: if there is subsampling on the // chroma planes, subsize must subsample to a valid block size. const struct macroblockd_plane *const pd_u = &xd->plane[1];
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c index 808b8b7..10d7b25 100644 --- a/av1/encoder/encodemb.c +++ b/av1/encoder/encodemb.c
@@ -484,7 +484,6 @@ for (plane = 0; plane < num_planes; ++plane) { const int subsampling_x = xd->plane[plane].subsampling_x; const int subsampling_y = xd->plane[plane].subsampling_y; - if (!is_chroma_reference(mi_row, mi_col, bsize, subsampling_x, subsampling_y)) continue; @@ -496,6 +495,7 @@ const struct macroblockd_plane *const pd = &xd->plane[plane]; const BLOCK_SIZE plane_bsize = get_plane_block_size(bsizec, pd->subsampling_x, pd->subsampling_y); + assert(plane_bsize < BLOCK_SIZES_ALL); const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0]; const int mi_height = block_size_high[plane_bsize] >> tx_size_high_log2[0]; const TX_SIZE max_tx_size = get_vartx_max_txsize(xd, plane_bsize, plane);
diff --git a/av1/encoder/ransac.c b/av1/encoder/ransac.c index 6a8854c..b490994 100644 --- a/av1/encoder/ransac.c +++ b/av1/encoder/ransac.c
@@ -265,8 +265,10 @@ } static int find_affine(int np, double *pts1, double *pts2, double *mat) { + assert(np > 0); const int np2 = np * 2; double *a = (double *)aom_malloc(sizeof(*a) * (np2 * 7 + 42)); + if (a == NULL) return 1; double *b = a + np2 * 6; double *temp = b + np2; int i;
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index d3349bb..3741e1c 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -2197,8 +2197,13 @@ diff += ((blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]); uint64_t sse = aom_sum_squares_2d_i16(diff, diff_stride, visible_cols, visible_rows); - if (block_mse_q8 != NULL) - *block_mse_q8 = (unsigned int)((256 * sse) / (visible_cols * visible_rows)); + if (block_mse_q8 != NULL) { + if (visible_cols > 0 && visible_rows > 0) + *block_mse_q8 = + (unsigned int)((256 * sse) / (visible_cols * visible_rows)); + else + *block_mse_q8 = UINT_MAX; + } return sse; }
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c index 9b8e0eb..dc25ecd 100644 --- a/av1/encoder/tokenize.c +++ b/av1/encoder/tokenize.c
@@ -216,6 +216,7 @@ scale_chroma_bsize(bsize, pd->subsampling_x, pd->subsampling_y); const BLOCK_SIZE plane_bsize = get_plane_block_size(bsizec, pd->subsampling_x, pd->subsampling_y); + assert(plane_bsize < BLOCK_SIZES_ALL); const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0]; const int mi_height = block_size_high[plane_bsize] >> tx_size_high_log2[0]; const TX_SIZE max_tx_size = get_vartx_max_txsize(xd, plane_bsize, plane);
diff --git a/common/obudec.c b/common/obudec.c index bd9f98d..1ce218d 100644 --- a/common/obudec.c +++ b/common/obudec.c
@@ -438,13 +438,15 @@ return -1; } #endif - uint8_t *new_buffer = (uint8_t *)realloc(*buffer, tu_size); - if (!new_buffer) { - free(*buffer); - fprintf(stderr, "obudec: Out of memory.\n"); - return -1; + if (tu_size > 0) { + uint8_t *new_buffer = (uint8_t *)realloc(*buffer, tu_size); + if (!new_buffer) { + free(*buffer); + fprintf(stderr, "obudec: Out of memory.\n"); + return -1; + } + *buffer = new_buffer; } - *buffer = new_buffer; *bytes_read = tu_size; *buffer_size = tu_size;
diff --git a/test/av1_inv_txfm1d_test.cc b/test/av1_inv_txfm1d_test.cc index bf3a44e..2926ae6 100644 --- a/test/av1_inv_txfm1d_test.cc +++ b/test/av1_inv_txfm1d_test.cc
@@ -88,9 +88,11 @@ memset(input + 32, 0, 32 * sizeof(input[0])); int32_t ref_output[64]; + memset(ref_output, 0, sizeof(ref_output)); reference_idct_1d_int(input, ref_output, tx_size_pix); int32_t output[64]; + memset(output, 0, sizeof(output)); inv_txfm_func(input, output, cos_bit, range_bit); for (int i = 0; i < tx_size_pix; ++i) {