Skip to content

Commit

Permalink
feat(core): early panic if the PNG icon is not RGBA
Browse files Browse the repository at this point in the history
  • Loading branch information
meowtec committed Apr 15, 2023
1 parent dfb5f52 commit cadfc51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/early-panic-for-png-not-rgba.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Early panic if the PNG icon is not RGBA.
7 changes: 7 additions & 0 deletions core/tauri-codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,13 @@ fn png_icon<P: AsRef<Path>>(
let mut reader = decoder
.read_info()
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e));

let (color_type, _) = reader.output_color_type();

if color_type != png::ColorType::Rgba {
panic!("icon {} is not RGBA", path.display());
}

let mut buffer: Vec<u8> = Vec::new();
while let Ok(Some(row)) = reader.next_row() {
buffer.extend(row.data());
Expand Down

0 comments on commit cadfc51

Please sign in to comment.