Skip to content

Commit

Permalink
TextureManager: use size_t for intermediate sizes to prevent possible…
Browse files Browse the repository at this point in the history
… integer overflow
  • Loading branch information
azonenberg committed Nov 14, 2024
1 parent ad40383 commit 88d8e8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib
6 changes: 3 additions & 3 deletions src/ngscopeclient/TextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ void TextureManager::LoadTexture(
auto rowPtrs = png_get_rows(png, info);

//Figure out the file dimensions
int width = png_get_image_width(png, info);
int height = png_get_image_height(png, info);
size_t width = png_get_image_width(png, info);
size_t height = png_get_image_height(png, info);
int depth = png_get_bit_depth(png, info);
if(png_get_color_type(png, info) != PNG_COLOR_TYPE_RGBA)
{
Expand All @@ -395,7 +395,7 @@ void TextureManager::LoadTexture(
return;
}
int bytesPerComponent = 1;
int bytesPerPixel = 4*bytesPerComponent;
size_t bytesPerPixel = 4*bytesPerComponent;
LogTrace("Image is %d x %d pixels, RGBA8888\n", width, height);
VkDeviceSize size = width * height * bytesPerPixel;

Expand Down

0 comments on commit 88d8e8b

Please sign in to comment.