diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index d2866fff49..a824e65914 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -2031,12 +2031,12 @@ hipError_t ihipMemcpyParam2D(const hip_Memcpy2D* pCopy, hipError_t ihipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream, bool isAsync = false) { hip_Memcpy2D desc = {}; - if (spitch == 0 || dpitch == 0) { - return hipErrorUnknown; - } - if (width == 0 || height == 0) { + if ((width == 0) || (height == 0)) { return hipSuccess; } + if ((width > dpitch) || (width > spitch)) { + return hipErrorInvalidPitchValue; + } desc.srcXInBytes = 0; desc.srcY = 0;