aboutsummaryrefslogtreecommitdiff
path: root/source/scale.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/scale.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/scale.cc')
-rw-r--r--source/scale.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/scale.cc b/source/scale.cc
index a8c70949..ac6a3bad 100644
--- a/source/scale.cc
+++ b/source/scale.cc
@@ -960,6 +960,7 @@ static void ScalePlaneBox(int src_width,
{
// Allocate a row buffer of uint16_t.
align_buffer_64(row16, src_width * 2);
+ if (!row16) return;
void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx,
const uint16_t* src_ptr, uint8_t* dst_ptr) =
(dx & 0xffff) ? ScaleAddCols2_C
@@ -1054,6 +1055,7 @@ static void ScalePlaneBox_16(int src_width,
{
// Allocate a row buffer of uint32_t.
align_buffer_64(row32, src_width * 4);
+ if (!row32) return;
void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx,
const uint32_t* src_ptr, uint16_t* dst_ptr) =
(dx & 0xffff) ? ScaleAddCols2_16_C : ScaleAddCols1_16_C;
@@ -1105,6 +1107,7 @@ static void ScalePlaneBilinearDown(int src_width,
// TODO(fbarchard): Consider not allocating row buffer for kFilterLinear.
// Allocate a row buffer.
align_buffer_64(row, src_width);
+ if (!row) return;
const int max_y = (src_height - 1) << 16;
int j;
@@ -1233,6 +1236,7 @@ static void ScalePlaneBilinearDown_16(int src_width,
// TODO(fbarchard): Consider not allocating row buffer for kFilterLinear.
// Allocate a row buffer.
align_buffer_64(row, src_width * 2);
+ if (!row) return;
const int max_y = (src_height - 1) << 16;
int j;
@@ -1415,6 +1419,7 @@ static void ScalePlaneBilinearUp(int src_width,
// Allocate 2 row buffers.
const int row_size = (dst_width + 31) & ~31;
align_buffer_64(row, row_size * 2);
+ if (!row) return;
uint8_t* rowptr = row;
int rowstride = row_size;
@@ -1882,6 +1887,7 @@ static void ScalePlaneBilinearUp_16(int src_width,
// Allocate 2 row buffers.
const int row_size = (dst_width + 31) & ~31;
align_buffer_64(row, row_size * 4);
+ if (!row) return;
uint16_t* rowptr = (uint16_t*)row;
int rowstride = row_size;