diff options
author | Frank Barchard <fbarchard@google.com> | 2023-10-27 10:12:13 -0700 |
---|---|---|
committer | libyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-10-27 17:41:36 +0000 |
commit | 31e1d6f896615342d5d5b6bde8f7b50b3fd698dc (patch) | |
tree | 685ffd3182496e78e4e23c45fdd3729501cca38c /source/convert_argb.cc | |
parent | 331c361581896292fb46c8c6905e41262b7ca95f (diff) | |
download | libyuv-31e1d6f896615342d5d5b6bde8f7b50b3fd698dc.tar.gz |
Check allocations that return NULL and return early
BUG=libyuv:968
Change-Id: I9e8594440a6035958511f9c50072820131331fc8
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4977552
Reviewed-by: Wan-Teh Chang <wtc@google.com>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/convert_argb.cc')
-rw-r--r-- | source/convert_argb.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/convert_argb.cc b/source/convert_argb.cc index 5c946c3a..ad4470c7 100644 --- a/source/convert_argb.cc +++ b/source/convert_argb.cc @@ -4670,6 +4670,7 @@ int Android420ToARGBMatrix(const uint8_t* src_y, // General case fallback creates NV12 align_buffer_64(plane_uv, halfwidth * 2 * halfheight); + if (!plane_uv) return 1; dst_uv = plane_uv; for (y = 0; y < halfheight; ++y) { WeavePixels(src_u, src_v, src_pixel_stride_uv, dst_uv, halfwidth); @@ -5982,6 +5983,7 @@ int I420ToRGB565Dither(const uint8_t* src_y, { // Allocate a row of argb. align_buffer_64(row_argb, width * 4); + if (!row_argb) return 1; for (y = 0; y < height; ++y) { I422ToARGBRow(src_y, src_u, src_v, row_argb, &kYuvI601Constants, width); ARGBToRGB565DitherRow(row_argb, dst_rgb565, @@ -6240,6 +6242,7 @@ static int I420ToARGBMatrixBilinear(const uint8_t* src_y, // alloc 4 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 4); + if (!row) return 1; uint8_t* temp_u_1 = row; uint8_t* temp_u_2 = row + row_size; uint8_t* temp_v_1 = row + row_size * 2; @@ -6376,6 +6379,7 @@ static int I422ToARGBMatrixLinear(const uint8_t* src_y, // alloc 2 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 2); + if (!row) return 1; uint8_t* temp_u = row; uint8_t* temp_v = row + row_size; @@ -6507,6 +6511,7 @@ static int I420ToRGB24MatrixBilinear(const uint8_t* src_y, // alloc 4 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 4); + if (!row) return 1; uint8_t* temp_u_1 = row; uint8_t* temp_u_2 = row + row_size; uint8_t* temp_v_1 = row + row_size * 2; @@ -6613,6 +6618,7 @@ static int I010ToAR30MatrixBilinear(const uint16_t* src_y, // alloc 4 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 4 * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_u_1 = (uint16_t*)(row); uint16_t* temp_u_2 = (uint16_t*)(row) + row_size; uint16_t* temp_v_1 = (uint16_t*)(row) + row_size * 2; @@ -6712,6 +6718,7 @@ static int I210ToAR30MatrixLinear(const uint16_t* src_y, // alloc 2 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 2 * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_u = (uint16_t*)(row); uint16_t* temp_v = (uint16_t*)(row) + row_size; @@ -6800,6 +6807,7 @@ static int I010ToARGBMatrixBilinear(const uint16_t* src_y, // alloc 4 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 4 * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_u_1 = (uint16_t*)(row); uint16_t* temp_u_2 = (uint16_t*)(row) + row_size; uint16_t* temp_v_1 = (uint16_t*)(row) + row_size * 2; @@ -6898,6 +6906,7 @@ static int I210ToARGBMatrixLinear(const uint16_t* src_y, // alloc 2 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 2 * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_u = (uint16_t*)(row); uint16_t* temp_v = (uint16_t*)(row) + row_size; @@ -7074,6 +7083,7 @@ static int I420AlphaToARGBMatrixBilinear( // alloc 4 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 4); + if (!row) return 1; uint8_t* temp_u_1 = row; uint8_t* temp_u_2 = row + row_size; uint8_t* temp_v_1 = row + row_size * 2; @@ -7274,6 +7284,7 @@ static int I422AlphaToARGBMatrixLinear(const uint8_t* src_y, // alloc 2 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 2); + if (!row) return 1; uint8_t* temp_u = row; uint8_t* temp_v = row + row_size; @@ -7413,6 +7424,7 @@ static int I010AlphaToARGBMatrixBilinear( // alloc 4 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 4 * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_u_1 = (uint16_t*)(row); uint16_t* temp_u_2 = (uint16_t*)(row) + row_size; uint16_t* temp_v_1 = (uint16_t*)(row) + row_size * 2; @@ -7574,6 +7586,7 @@ static int I210AlphaToARGBMatrixLinear(const uint16_t* src_y, // alloc 2 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 2 * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_u = (uint16_t*)(row); uint16_t* temp_v = (uint16_t*)(row) + row_size; @@ -7659,6 +7672,7 @@ static int P010ToARGBMatrixBilinear(const uint16_t* src_y, // alloc 2 lines temp const int row_size = (2 * width + 31) & ~31; align_buffer_64(row, row_size * 2 * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_uv_1 = (uint16_t*)(row); uint16_t* temp_uv_2 = (uint16_t*)(row) + row_size; @@ -7749,6 +7763,7 @@ static int P210ToARGBMatrixLinear(const uint16_t* src_y, const int row_size = (2 * width + 31) & ~31; align_buffer_64(row, row_size * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_uv = (uint16_t*)(row); for (y = 0; y < height; ++y) { @@ -7827,6 +7842,7 @@ static int P010ToAR30MatrixBilinear(const uint16_t* src_y, // alloc 2 lines temp const int row_size = (2 * width + 31) & ~31; align_buffer_64(row, row_size * 2 * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_uv_1 = (uint16_t*)(row); uint16_t* temp_uv_2 = (uint16_t*)(row) + row_size; @@ -7917,6 +7933,7 @@ static int P210ToAR30MatrixLinear(const uint16_t* src_y, const int row_size = (2 * width + 31) & ~31; align_buffer_64(row, row_size * sizeof(uint16_t)); + if (!row) return 1; uint16_t* temp_uv = (uint16_t*)(row); for (y = 0; y < height; ++y) { @@ -8017,6 +8034,7 @@ static int I422ToRGB24MatrixLinear(const uint8_t* src_y, // alloc 2 lines temp const int row_size = (width + 31) & ~31; align_buffer_64(row, row_size * 2); + if (!row) return 1; uint8_t* temp_u = row; uint8_t* temp_v = row + row_size; |