diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index 665c9aa998..58133d981c 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -1063,7 +1063,7 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder, imageType, CL_MEM_READ_WRITE, imageFormat, - (imageWidth == 0) ? 1 : imageWidth, + imageWidth, (imageHeight == 0) ? 1 : imageHeight, (imageDepth == 0) ? 1 : imageDepth, imageRowPitch, diff --git a/projects/clr/rocclr/platform/memory.cpp b/projects/clr/rocclr/platform/memory.cpp index c376d0abf6..a887a2c95a 100644 --- a/projects/clr/rocclr/platform/memory.cpp +++ b/projects/clr/rocclr/platform/memory.cpp @@ -675,6 +675,10 @@ bool Image::validateDimensions(const std::vector& devices, cl_mem_ } // Fall through... case CL_MEM_OBJECT_IMAGE2D: + if ((width == 0) || (height == 0)) { + DevLogPrintfError("Invalid dimensions width: %u height: %u \n", width, height); + return false; + } for (const auto dev : devices) { if ((dev->info().image2DMaxHeight_ >= height) && (dev->info().image2DMaxWidth_ >= width)) { return true; @@ -710,6 +714,10 @@ bool Image::validateDimensions(const std::vector& devices, cl_mem_ } break; case CL_MEM_OBJECT_IMAGE1D_BUFFER: + if (width == 0) { + DevLogError("Invalid dimension \n"); + return false; + } for (const auto& dev : devices) { if (dev->info().imageMaxBufferSize_ >= width) { return true;