feat(core): early panic if the PNG icon is not RGBA, closes #6706 (#6712)

This commit is contained in:
Bo 2023-05-26 15:26:21 +08:00 committed by GitHub
parent d68a25e32e
commit 17d5a4f51f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-codegen": 'patch:enhance'
---
Early panic if the PNG icon is not RGBA.

View File

@ -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());