From 25ba0211486c7fccd3d5bd024ee1ccece4f56a1b Mon Sep 17 00:00:00 2001 From: "mikhal@webrtc.org" Date: Thu, 19 Jul 2012 16:38:27 +0000 Subject: [PATCH] LibYuv:Adding input checks (open TODO: Add unit tests) Review URL: https://webrtc-codereview.appspot.com/698004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@309 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- source/convert.cc | 96 +++++++++++++++++++++++++++++++++++++++--- source/convert_argb.cc | 86 +++++++++++++++++++++++++++++++++++-- source/convert_from.cc | 79 +++++++++++++++++++++++++++++++--- 3 files changed, 244 insertions(+), 17 deletions(-) diff --git a/source/convert.cc b/source/convert.cc index 2fd5e506c..dbed9601c 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -127,6 +127,11 @@ int I422ToI420(const uint8* src_y, int src_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -201,6 +206,11 @@ int I444ToI420(const uint8* src_y, int src_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -273,6 +283,11 @@ int I411ToI420(const uint8* src_y, int src_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -315,6 +330,10 @@ int I400ToI420(const uint8* src_y, int src_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -379,6 +398,11 @@ static int X420ToI420(const uint8* src_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !src_uv || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -572,6 +596,11 @@ int Q420ToI420(const uint8* src_y, int src_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !src_yuy2 || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -738,6 +767,11 @@ int UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_uyvy || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -840,7 +874,10 @@ int V210ToI420(const uint8* src_v210, int src_stride_v210, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { - if (width * 2 * 2 > kMaxStride) { // 2 rows of UYVY is required + if (width * 2 * 2 > kMaxStride) { // 2 rows of UYVY are required. + return -1; + } else if (!src_v210 || !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { return -1; } // Negative height means invert the image. @@ -892,6 +929,12 @@ int ARGBToI420(const uint8* src_argb, int src_stride_argb, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_argb || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; @@ -943,6 +986,12 @@ int BGRAToI420(const uint8* src_bgra, int src_stride_bgra, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_bgra || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_bgra = src_bgra + (height - 1) * src_stride_bgra; @@ -994,6 +1043,12 @@ int ABGRToI420(const uint8* src_abgr, int src_stride_abgr, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_abgr || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_abgr = src_abgr + (height - 1) * src_stride_abgr; @@ -1045,9 +1100,14 @@ int RGB24ToI420(const uint8* src_rgb24, int src_stride_rgb24, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { - if (width * 4 > kMaxStride) { // row buffer is required + if (width * 4 > kMaxStride) { // Row buffer is required. return -1; + } else if (!src_rgb24 || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; } + // Negative height means invert the image. if (height < 0) { height = -height; src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24; @@ -1110,9 +1170,14 @@ int RAWToI420(const uint8* src_raw, int src_stride_raw, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { - if (width * 4 > kMaxStride) { // row buffer is required + if (width * 4 > kMaxStride) { // Row buffer is required. return -1; + } else if (!src_raw || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; } + // Negative height means invert the image. if (height < 0) { height = -height; src_raw = src_raw + (height - 1) * src_stride_raw; @@ -1175,9 +1240,14 @@ int RGB565ToI420(const uint8* src_rgb565, int src_stride_rgb565, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { - if (width * 4 > kMaxStride) { // row buffer is required + if (width * 4 > kMaxStride) { // Row buffer is required. + return -1; + } else if (!src_rgb565 || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { return -1; } + // Negative height means invert the image. if (height < 0) { height = -height; src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565; @@ -1240,9 +1310,14 @@ int ARGB1555ToI420(const uint8* src_argb1555, int src_stride_argb1555, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { - if (width * 4 > kMaxStride) { // row buffer is required + if (width * 4 > kMaxStride) { // Row buffer is required. return -1; + } else if (!src_argb1555 || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; } + // Negative height means invert the image. if (height < 0) { height = -height; src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555; @@ -1306,9 +1381,14 @@ int ARGB4444ToI420(const uint8* src_argb4444, int src_stride_argb4444, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { - if (width * 4 > kMaxStride) { // row buffer is required + if (width * 4 > kMaxStride) { // Row buffer is required. return -1; + } else if (!src_argb4444 || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; } + // Negative height means invert the image. if (height < 0) { height = -height; src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444; @@ -1569,7 +1649,9 @@ int ConvertToI420(const uint8* sample, size_t sample_size, int dst_width, int dst_height, RotationMode rotation, uint32 format) { - if (y == NULL || u == NULL || v == NULL || sample == NULL) { + if (!y || !u || !v || !sample || + src_width <= 0 || dst_width <= 0 || + src_height == 0 || dst_height == 0) { return -1; } int aligned_src_width = (src_width + 1) & ~1; diff --git a/source/convert_argb.cc b/source/convert_argb.cc index e7b81229c..e0506bcee 100644 --- a/source/convert_argb.cc +++ b/source/convert_argb.cc @@ -30,8 +30,7 @@ extern "C" { int ARGBCopy(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height) { - if (!src_argb || - !dst_argb || + if (!src_argb || !dst_argb || width <= 0 || height == 0) { return -1; } @@ -53,6 +52,11 @@ int I444ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -92,6 +96,11 @@ int I422ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -138,6 +147,11 @@ int I411ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -176,6 +190,10 @@ int I411ToARGB(const uint8* src_y, int src_stride_y, int I400ToARGB_Reference(const uint8* src_y, int src_stride_y, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -205,6 +223,11 @@ int I400ToARGB_Reference(const uint8* src_y, int src_stride_y, int I400ToARGB(const uint8* src_y, int src_stride_y, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !dst_argb || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; @@ -232,6 +255,11 @@ int I400ToARGB(const uint8* src_y, int src_stride_y, int ABGRToARGB(const uint8* src_abgr, int src_stride_abgr, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_abgr || !dst_argb || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_abgr = src_abgr + (height - 1) * src_stride_abgr; @@ -260,6 +288,11 @@ int ABGRToARGB(const uint8* src_abgr, int src_stride_abgr, int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_bgra || !dst_argb || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_bgra = src_bgra + (height - 1) * src_stride_bgra; @@ -288,6 +321,11 @@ int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra, int RAWToARGB(const uint8* src_raw, int src_stride_raw, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_raw || !dst_argb || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_raw = src_raw + (height - 1) * src_stride_raw; @@ -315,6 +353,11 @@ int RAWToARGB(const uint8* src_raw, int src_stride_raw, int RGB24ToARGB(const uint8* src_rgb24, int src_stride_rgb24, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_rgb24 || !dst_argb || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24; @@ -342,6 +385,11 @@ int RGB24ToARGB(const uint8* src_rgb24, int src_stride_rgb24, int RGB565ToARGB(const uint8* src_rgb565, int src_stride_rgb565, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_rgb565 || !dst_argb || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565; @@ -369,6 +417,11 @@ int RGB565ToARGB(const uint8* src_rgb565, int src_stride_rgb565, int ARGB1555ToARGB(const uint8* src_argb1555, int src_stride_argb1555, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_argb1555 || !dst_argb || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555; @@ -396,6 +449,11 @@ int ARGB1555ToARGB(const uint8* src_argb1555, int src_stride_argb1555, int ARGB4444ToARGB(const uint8* src_argb4444, int src_stride_argb4444, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_argb4444 || !dst_argb || + width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. if (height < 0) { height = -height; src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444; @@ -424,6 +482,10 @@ int NV12ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_uv, int src_stride_uv, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_uv || !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -462,6 +524,10 @@ int NV21ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_vu, int src_stride_vu, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_vu || !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -499,6 +565,10 @@ int NV21ToARGB(const uint8* src_y, int src_stride_y, int M420ToARGB(const uint8* src_m420, int src_stride_m420, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_m420 || !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -538,6 +608,10 @@ int M420ToARGB(const uint8* src_m420, int src_stride_m420, int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_yuy2 || !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -604,6 +678,10 @@ int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2, int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_uyvy || !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -840,7 +918,9 @@ int ConvertToARGB(const uint8* sample, size_t sample_size, int dst_width, int dst_height, RotationMode rotation, uint32 format) { - if (dst_argb == NULL || sample == NULL) { + if (dst_argb == NULL || sample == NULL || + src_width <= 0 || dst_width <= 0 || + src_height == 0 || dst_height == 0) { return -1; } int aligned_src_width = (src_width + 1) & ~1; diff --git a/source/convert_from.cc b/source/convert_from.cc index 3ac3d7b1e..6725419d1 100644 --- a/source/convert_from.cc +++ b/source/convert_from.cc @@ -31,6 +31,11 @@ int I420ToI422(const uint8* src_y, int src_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -105,6 +110,11 @@ int I420ToI444(const uint8* src_y, int src_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !src_u|| !src_v || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -149,6 +159,11 @@ int I420ToI411(const uint8* src_y, int src_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_y || !dst_u || !dst_v || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -189,6 +204,10 @@ int I420ToI411(const uint8* src_y, int src_stride_y, int I400Copy(const uint8* src_y, int src_stride_y, uint8* dst_y, int dst_stride_y, int width, int height) { + if (!src_y || !dst_y || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -446,7 +465,8 @@ int I422ToYUY2(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height) { - if (src_y == NULL || src_u == NULL || src_v == NULL || dst_frame == NULL) { + if (!src_y || !src_u || !src_v || !dst_frame || + width <= 0 || height == 0) { return -1; } // Negative height means invert the image. @@ -482,7 +502,8 @@ int I420ToYUY2(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height) { - if (src_y == NULL || src_u == NULL || src_v == NULL || dst_frame == NULL) { + if (!src_y || !src_u || !src_v || !dst_frame || + width <= 0 || height == 0) { return -1; } // Negative height means invert the image. @@ -524,7 +545,8 @@ int I422ToUYVY(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height) { - if (src_y == NULL || src_u == NULL || src_v == NULL || dst_frame == NULL) { + if (!src_y || !src_u || !src_v || !dst_frame || + width <= 0 || height == 0) { return -1; } // Negative height means invert the image. @@ -560,7 +582,8 @@ int I420ToUYVY(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height) { - if (src_y == NULL || src_u == NULL || src_v == NULL || dst_frame == NULL) { + if (!src_y || !src_u || !src_v || !dst_frame || + width <= 0 || height <= 0 ) { return -1; } // Negative height means invert the image. @@ -601,8 +624,10 @@ int I420ToV210(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height) { - if (width * 16 / 6 > kMaxStride || // Row buffer of V210 is required. - src_y == NULL || src_u == NULL || src_v == NULL || dst_frame == NULL) { + if (width * 16 / 6 > kMaxStride) { // Row buffer of V210 is required. + return -1; + } else if (!src_y || !src_u || !src_v || !dst_frame || + width <= 0 || height == 0) { return -1; } // Negative height means invert the image. @@ -651,6 +676,10 @@ int I420ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_u || !src_v || !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -699,6 +728,11 @@ int I420ToBGRA(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_bgra, int dst_stride_bgra, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_bgra || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -747,6 +781,11 @@ int I420ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_abgr, int dst_stride_abgr, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_abgr || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -795,6 +834,11 @@ int I420ToRGB24(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -850,6 +894,11 @@ int I420ToRAW(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -905,6 +954,11 @@ int I420ToRGB565(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_rgb, int dst_stride_rgb, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_rgb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -959,6 +1013,11 @@ int I420ToARGB1555(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -1013,6 +1072,11 @@ int I420ToARGB4444(const uint8* src_y, int src_stride_y, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height) { + if (!src_y || !src_u || !src_v || + !dst_argb || + width <= 0 || height == 0) { + return -1; + } // Negative height means invert the image. if (height < 0) { height = -height; @@ -1068,7 +1132,8 @@ int ConvertFromI420(const uint8* y, int y_stride, uint8* dst_sample, int dst_sample_stride, int width, int height, uint32 format) { - if (y == NULL || u == NULL || v == NULL || dst_sample == NULL) { + if (!y || !u|| !v || !dst_sample || + width <= 0 || height == 0) { return -1; } int r = 0;