Skip to content

Commit

Permalink
Prevent overflow when loading high resolution textures in certain cod…
Browse files Browse the repository at this point in the history
…e paths

With the release of Dawntrail, these are now being hit - for example loading the
expansion logo in Astra. These are now converted to usize everywhere so it
prevents this from happening.
  • Loading branch information
redstrate committed Jun 27, 2024
1 parent 6700d1f commit 39d7a5b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Texture {
let mut offset = 0;
let mut dst_offset = 0;

for _ in 0..header.width * header.height {
for _ in 0..header.width as usize * header.height as usize {
let short: u16 = ((src[offset] as u16) << 8) | src[offset + 1] as u16;

let src_b = short & 0xF;
Expand All @@ -146,7 +146,7 @@ impl Texture {

let mut offset = 0;

for _ in 0..header.width * header.height * header.depth {
for _ in 0..header.width as usize * header.height as usize * header.depth as usize {
let src_b = src[offset];
let src_g = src[offset + 1];
let src_r = src[offset + 2];
Expand Down

0 comments on commit 39d7a5b

Please sign in to comment.