diff --git a/projects/clr/hipamd/src/hip_graph.cpp b/projects/clr/hipamd/src/hip_graph.cpp index a8e5419ff6..edeb1a6126 100644 --- a/projects/clr/hipamd/src/hip_graph.cpp +++ b/projects/clr/hipamd/src/hip_graph.cpp @@ -134,7 +134,10 @@ hipError_t ihipGraphAddMemsetNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, ihipMemset_validate(pMemsetParams->dst, pMemsetParams->value, pMemsetParams->elementSize, pMemsetParams->width * pMemsetParams->elementSize); } else { - auto sizeBytes = pMemsetParams->width * pMemsetParams->height * 1; + if (pMemsetParams->pitch < (pMemsetParams->width * pMemsetParams->elementSize)) { + return hipErrorInvalidValue; + } + auto sizeBytes = pMemsetParams->width * pMemsetParams->height * pMemsetParams->elementSize * 1; status = ihipMemset3D_validate( {pMemsetParams->dst, pMemsetParams->pitch, pMemsetParams->width, pMemsetParams->height}, pMemsetParams->value, {pMemsetParams->width, pMemsetParams->height, 1}, sizeBytes); @@ -1363,6 +1366,9 @@ hipError_t hipGraphMemsetNodeSetParams(hipGraphNode_t node, const hipMemsetParam if (node == nullptr || pNodeParams == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + if (pNodeParams->height > 1 && pNodeParams->pitch < (pNodeParams->width * pNodeParams->elementSize)) { + return hipErrorInvalidValue; + } HIP_RETURN(reinterpret_cast(node)->SetParams(pNodeParams)); }