From 6bb34eaa644820b142b6e6fee848a218f89eaeae Mon Sep 17 00:00:00 2001 From: xulei2020 <“xulei83@huawei.com”> Date: Mon, 28 Sep 2020 14:12:21 +0800 Subject: [PATCH] add input param check --- .../minddata/dataset/kernels/image/lite_cv/image_process.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc index 4aa9e530cc..b494d7f97e 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc @@ -294,6 +294,9 @@ static bool ConvertRGBAToGRAY(const unsigned char *data, LDataType data_type, in } bool InitFromPixel(const unsigned char *data, LPixelType pixel_type, LDataType data_type, int w, int h, LiteMat &m) { + if (data == nullptr) { + return false; + } if (w <= 0 || h <= 0) { return false; } @@ -517,6 +520,9 @@ bool Pad(const LiteMat &src, LiteMat &dst, int top, int bottom, int left, int ri if (top <= 0 || bottom <= 0 || left <= 0 || right <= 0) { return false; } + if (src.IsEmpty()) { + return false; + } if (pad_type == PADD_BORDER_CONSTANT && src.data_type_ == LDataType::FLOAT32) { PadWithConstant(src, dst, top, bottom, left, right, pad_type, fill_b_or_gray, fill_g, fill_r); } else if (pad_type == PADD_BORDER_CONSTANT && src.data_type_ == LDataType::UINT8) {