Skip to content

Commit

Permalink
Validate texture sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Jun 29, 2024
1 parent 6e1d16f commit 7caf9ea
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/graphics/src/loaders/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ fn load_wgpu_texture_from_path(
let file = filesystem.read(path)?;
let texture_data = image::load_from_memory(&file)?.to_rgba8();

if device.limits().max_texture_dimension_2d < texture_data.width().max(texture_data.height()) {
return Err(color_eyre::eyre::eyre!(
"Texture is too large: {}x{}",
texture_data.width(),
texture_data.height()
));
}

Ok(load_wgpu_texture_from_image(
&texture_data,
device,
Expand Down

0 comments on commit 7caf9ea

Please sign in to comment.