Skip to content

Commit 965a602

Browse files
authored
tga: adjust colormap lookup to match tga 2.0 spec (#2608)
1 parent 288ccc7 commit 965a602

File tree

3 files changed

+1
-2
lines changed

3 files changed

+1
-2
lines changed

src/codecs/tga/decoder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ struct ColorMap {
2020
impl ColorMap {
2121
/// Get one entry from the color map
2222
pub(crate) fn get(&self, index: usize) -> Option<&[u8]> {
23-
// TODO: Should we actually be *subtracting* start_offset from the index here?
24-
let entry = self.start_offset + self.entry_size * index;
23+
let entry = self.entry_size * index.checked_sub(self.start_offset)?;
2524
self.bytes.get(entry..entry + self.entry_size)
2625
}
2726
}
326 Bytes
Binary file not shown.
290 Bytes
Loading

0 commit comments

Comments
 (0)