Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| fn decode_bc3_top_mip_to_rgba(src: &[u8], w: usize, h: usize) -> Result<Vec<u8>> { | ||
| let bw = (w + 3) / 4; | ||
| let bh = (h + 3) / 4; | ||
| let mut rgba = vec![0u8; w * h * 4]; | ||
| let pitch = w * 4; | ||
| let bpb = 16usize; | ||
| for y in 0..bh { | ||
| for x in 0..bw { | ||
| let off = (y * bw + x) * bpb; | ||
| let block = &src[off..off + bpb]; | ||
| let mut tmp = [0u8; 4 * 4 * 4]; | ||
| bcdec_rs::bc3(block, &mut tmp, 4 * 4); | ||
| for row in 0..4 { | ||
| let dst = (y * 4 + row) * pitch + x * 4 * 4; | ||
| let src_row = row * 4 * 4; | ||
| rgba[dst..dst + 4 * 4] | ||
| .copy_from_slice(&tmp[src_row..src_row + 4 * 4]); | ||
| } |
There was a problem hiding this comment.
[P1] Handle partial BC3 blocks to avoid slice overflow
decode_bc3_top_mip_to_rgba writes a full 4×4 block into rgba for every block index without checking whether the block overlaps the image edge. For textures whose width or height is not divisible by four (valid BC3 data is typically padded but may represent, e.g., 100×50 UI textures), the computed range rgba[dst..dst + 16] exceeds the w * h * 4 buffer, causing a panic when the last partial block is processed. The BC1 decoder below guards each pixel with if x < w && y < h; BC3 needs similar bounds checks or cropping before copying rows.
Useful? React with 👍 / 👎.
Summary
Testing
cargo checkhttps://chatgpt.com/codex/tasks/task_e_68bc3ce187408320a6f3afb32b97fd14