Skip to content

Commit

Permalink
Runtime: Fix a CodeQL warning due to potential overflow
Browse files Browse the repository at this point in the history
Surely RML won't try to create textures that can overflow a uint32_t value here? Using size_t as input is required by the wgpu API.
  • Loading branch information
Duckwhale committed Feb 8, 2024
1 parent 92d0c09 commit 0cdfccf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Runtime/Bindings/RmlUi_Renderer_WebGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ WGPUBuffer RenderInterface_WebGPU::CreateIndexBuffer(int* indices, int num_indic
}

WGPUTexture RenderInterface_WebGPU::CreateTexture(const uint8_t* rgbaImageBytes, const uint32_t textureWidth, const uint32_t textureHeight) {
size_t textureBufferSize = textureWidth * textureHeight * 4; // RGBA
constexpr size_t BPP = 4; // RGBA texture format is assumed
size_t textureBufferSize = static_cast<size_t>(textureWidth) * static_cast<size_t>(textureHeight) * BPP;

WGPUTextureDescriptor textureDescriptor = {
.usage = WGPUTextureUsage_CopyDst | WGPUTextureUsage_TextureBinding,
Expand Down

0 comments on commit 0cdfccf

Please sign in to comment.