diff --git a/src/fuzzers/D3D12Fuzzer.cpp b/src/fuzzers/D3D12Fuzzer.cpp index 329c0f0f6..a96a85915 100644 --- a/src/fuzzers/D3D12Fuzzer.cpp +++ b/src/fuzzers/D3D12Fuzzer.cpp @@ -16,7 +16,7 @@ uint64_t UInt8ToUInt64(const uint8_t* src) { uint64_t dst; - memcpy(&dst, src, sizeof(uint64_t)); + memcpy_s(&dst, sizeof(uint64_t), src, sizeof(uint8_t)); return dst; } diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index 6241a155b..8e6f92dc3 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -1461,7 +1461,8 @@ namespace gpgmm::d3d12 { } data.IsResourceAllocationWithinCoherent = mCaps->IsResourceAllocationWithinCoherent(); - memcpy(pFeatureSupportData, &data, featureSupportDataSize); + memcpy_s(pFeatureSupportData, sizeof(pFeatureSupportData), &data, + featureSupportDataSize); return S_OK; } default: { diff --git a/src/tests/end2end/D3D12ResourceAllocatorTests.cpp b/src/tests/end2end/D3D12ResourceAllocatorTests.cpp index fb576a677..073aa3854 100644 --- a/src/tests/end2end/D3D12ResourceAllocatorTests.cpp +++ b/src/tests/end2end/D3D12ResourceAllocatorTests.cpp @@ -1166,21 +1166,21 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferWithinMany) { 0xCC); void* mappedBufferC = nullptr; ASSERT_SUCCEEDED(smallBufferC->Map(/*subresource*/ 0, nullptr, &mappedBufferC)); - memcpy(mappedBufferC, dataCC.data(), dataCC.size()); + memcpy_s(mappedBufferC, smallBufferC->GetInfo().SizeInBytes, dataCC.data(), dataCC.size()); // Fill small buffer A with value 0xAA. std::vector dataAA(static_cast(smallBufferA->GetInfo().SizeInBytes), 0xAA); void* mappedBufferA = nullptr; ASSERT_SUCCEEDED(smallBufferA->Map(/*subresource*/ 0, nullptr, &mappedBufferA)); - memcpy(mappedBufferA, dataAA.data(), dataAA.size()); + memcpy_s(mappedBufferA, smallBufferA->GetInfo().SizeInBytes, dataAA.data(), dataAA.size()); // Fill small buffer B with value 0xBB. std::vector dataBB(static_cast(smallBufferB->GetInfo().SizeInBytes), 0xBB); void* mappedBufferB = nullptr; ASSERT_SUCCEEDED(smallBufferB->Map(/*subresource*/ 0, nullptr, &mappedBufferB)); - memcpy(mappedBufferB, dataBB.data(), dataBB.size()); + memcpy_s(mappedBufferB, smallBufferB->GetInfo().SizeInBytes, dataBB.data(), dataBB.size()); EXPECT_NE(mappedBufferA, mappedBufferB); EXPECT_NE(mappedBufferB, mappedBufferC);