Skip to content

Commit

Permalink
Fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
emmabritton committed Jan 4, 2024
1 parent 532d25a commit d659492
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
toolchain: stable
override: true
- run: cargo fmt --all -- --check
- run: cargo test
- run: cargo clippy --all -- -D warnings
- run: cargo publish --token ${CRATES_TOKEN}
env:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### Version 0.1.5
- Fix crash with large palette sizes

### Version 0.1.4
- Add `width()` and `height()` for `AnimatedIndexedImage`

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ici-files"
version = "0.1.4"
version = "0.1.5"
edition = "2021"
authors = ["Emma Britton <emmabritton@pm.me>"]
description = "Encode/decode ici files"
Expand Down
14 changes: 7 additions & 7 deletions src/animated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,32 +977,32 @@ mod test {
Once,
)
.unwrap();
assert!(!image.animate());
assert!(!image.animating());
assert_eq!(image.get_current_frame_pixels(), &[0]);
image.update(1.0);
image.update(0.1);
assert_eq!(image.get_current_frame_pixels(), &[0]);
image.set_animate(true);
assert!(image.animate());
assert!(image.animating());
image.update(1.0);
image.update(0.1);
assert!(image.animate());
assert!(image.animating());
assert_eq!(image.get_current_frame_pixels(), &[1]);
image.update(1.0);
image.update(0.1);
assert!(image.animate());
assert!(image.animating());
assert_eq!(image.get_current_frame_pixels(), &[2]);
image.update(1.0);
image.update(0.1);
assert!(image.animate());
assert!(image.animating());
assert_eq!(image.get_current_frame_pixels(), &[3]);
image.update(1.0);
image.update(0.1);
assert!(!image.animate());
assert!(!image.animating());
assert_eq!(image.get_current_frame_pixels(), &[0]);
image.update(1.0);
image.update(0.1);
assert!(!image.animate());
assert!(!image.animating());
assert_eq!(image.get_current_frame_pixels(), &[0]);
}
}
2 changes: 1 addition & 1 deletion src/palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub(crate) fn read(
}
let count = bytes[start_idx];
start_idx += 1;
let end = (count * 4) as usize;
let end = count as usize * 4;
if bytes.len() < start_idx + end {
return Err(InvalidFileFormat(
start_idx,
Expand Down

0 comments on commit d659492

Please sign in to comment.