aboutsummaryrefslogtreecommitdiff
path: root/source/convert_from_argb.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2023-10-27 10:12:13 -0700
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-10-27 17:41:36 +0000
commit31e1d6f896615342d5d5b6bde8f7b50b3fd698dc (patch)
tree685ffd3182496e78e4e23c45fdd3729501cca38c /source/convert_from_argb.cc
parent331c361581896292fb46c8c6905e41262b7ca95f (diff)
downloadlibyuv-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_from_argb.cc')
-rw-r--r--source/convert_from_argb.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/convert_from_argb.cc b/source/convert_from_argb.cc
index 96129d84..1c0d250d 100644
--- a/source/convert_from_argb.cc
+++ b/source/convert_from_argb.cc
@@ -462,6 +462,7 @@ int ARGBToNV12(const uint8_t* src_argb,
{
// Allocate a rows of uv.
align_buffer_64(row_u, ((halfwidth + 31) & ~31) * 2);
+ if (!row_u) return 1;
uint8_t* row_v = row_u + ((halfwidth + 31) & ~31);
for (y = 0; y < height - 1; y += 2) {
@@ -660,6 +661,7 @@ int ARGBToNV21(const uint8_t* src_argb,
{
// Allocate a rows of uv.
align_buffer_64(row_u, ((halfwidth + 31) & ~31) * 2);
+ if (!row_u) return 1;
uint8_t* row_v = row_u + ((halfwidth + 31) & ~31);
for (y = 0; y < height - 1; y += 2) {
@@ -845,6 +847,7 @@ int ABGRToNV12(const uint8_t* src_abgr,
{
// Allocate a rows of uv.
align_buffer_64(row_u, ((halfwidth + 31) & ~31) * 2);
+ if (!row_u) return 1;
uint8_t* row_v = row_u + ((halfwidth + 31) & ~31);
for (y = 0; y < height - 1; y += 2) {
@@ -1031,6 +1034,7 @@ int ABGRToNV21(const uint8_t* src_abgr,
{
// Allocate a rows of uv.
align_buffer_64(row_u, ((halfwidth + 31) & ~31) * 2);
+ if (!row_u) return 1;
uint8_t* row_v = row_u + ((halfwidth + 31) & ~31);
for (y = 0; y < height - 1; y += 2) {
@@ -1230,6 +1234,7 @@ int ARGBToYUY2(const uint8_t* src_argb,
{
// Allocate a rows of yuv.
align_buffer_64(row_y, ((width + 63) & ~63) * 2);
+ if (!row_y) return 1;
uint8_t* row_u = row_y + ((width + 63) & ~63);
uint8_t* row_v = row_u + ((width + 63) & ~63) / 2;
@@ -1424,6 +1429,7 @@ int ARGBToUYVY(const uint8_t* src_argb,
{
// Allocate a rows of yuv.
align_buffer_64(row_y, ((width + 63) & ~63) * 2);
+ if (!row_y) return 1;
uint8_t* row_u = row_y + ((width + 63) & ~63);
uint8_t* row_v = row_u + ((width + 63) & ~63) / 2;
@@ -3274,11 +3280,13 @@ int RAWToJNV21(const uint8_t* src_raw,
{
// Allocate a row of uv.
align_buffer_64(row_uj, ((halfwidth + 31) & ~31) * 2);
+ if (!row_uj) return 1;
uint8_t* row_vj = row_uj + ((halfwidth + 31) & ~31);
#if !defined(HAS_RAWTOYJROW)
// Allocate 2 rows of ARGB.
const int row_size = (width * 4 + 31) & ~31;
align_buffer_64(row, row_size * 2);
+ if (!row) return 1;
#endif
for (y = 0; y < height - 1; y += 2) {