From 796de4f0668cc4b38f9e8653a0b2f53f0b3423b9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 14 Dec 2020 14:24:00 +0100 Subject: [PATCH] Prevent copy in texture upload with invalid input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip the memcpy when src is null. Also silences a Codechecker warning. Pick-to: 6.0 Change-Id: I5042d725000cb6dff6864408fa9ed9e0ca35145a Reviewed-by: Christian Strømme --- src/gui/rhi/qrhivulkan.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index f867781d8bb..232b1be4086 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -2923,8 +2923,10 @@ void QRhiVulkan::prepareUploadSubres(QVkTexture *texD, int layer, int level, qWarning("Invalid texture upload for %p layer=%d mip=%d", texD, layer, level); } - memcpy(reinterpret_cast(mp) + *curOfs, src, size_t(copySizeBytes)); - *curOfs += aligned(VkDeviceSize(imageSizeBytes), texbufAlign); + if (src) { + memcpy(reinterpret_cast(mp) + *curOfs, src, size_t(copySizeBytes)); + *curOfs += aligned(VkDeviceSize(imageSizeBytes), texbufAlign); + } } void QRhiVulkan::enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdateBatch *resourceUpdates)