Fix CopyExternalTextureForBrowserTests overflow.

The call to Queue::WriteTexture was passing a size that was bigger than
the array of data being used. This caused an ASAN failure when running
with the wire, because the serialization of the command would memcpy
past the end of the data.

Bug: dawn:1625
Change-Id: I2a00f2e32e3d8f8ff66d85575d1908480861f153
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116288
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Corentin Wallez 2023-01-06 14:28:24 +00:00 committed by Dawn LUCI CQ
parent 1ec6e861ec
commit 00208bd134
1 changed files with 4 additions and 2 deletions

View File

@ -77,7 +77,8 @@ class CopyExternalTextureForBrowserTests : public Parent {
wgpu::TextureDataLayout externalTexturePlane0DataLayout = {};
externalTexturePlane0DataLayout.bytesPerRow = 4;
this->queue.WriteTexture(&plane0, yPlaneData.data(), yPlaneData.size() * sizeof(float),
this->queue.WriteTexture(&plane0, yPlaneData.data(),
yPlaneData.size() * sizeof(yPlaneData[0]),
&externalTexturePlane0DataLayout, &externalTexturePlane0Desc.size);
// uv plane
@ -99,7 +100,8 @@ class CopyExternalTextureForBrowserTests : public Parent {
wgpu::TextureDataLayout externalTexturePlane1DataLayout = {};
externalTexturePlane1DataLayout.bytesPerRow = 4;
this->queue.WriteTexture(&plane1, uvPlaneData.data(), uvPlaneData.size() * sizeof(float),
this->queue.WriteTexture(&plane1, uvPlaneData.data(),
uvPlaneData.size() * sizeof(uvPlaneData[0]),
&externalTexturePlane1DataLayout, &externalTexturePlane1Desc.size);
// Create an ExternalTextureDescriptor from the texture views