From cadfc51e6167210dd31a76cb8115ce0460bd6c61 Mon Sep 17 00:00:00 2001 From: meowtec Date: Sat, 15 Apr 2023 23:15:34 +0800 Subject: [PATCH] feat(core): early panic if the PNG icon is not RGBA --- .changes/early-panic-for-png-not-rgba.md | 5 +++++ core/tauri-codegen/src/context.rs | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changes/early-panic-for-png-not-rgba.md diff --git a/.changes/early-panic-for-png-not-rgba.md b/.changes/early-panic-for-png-not-rgba.md new file mode 100644 index 000000000000..463ee5675d0f --- /dev/null +++ b/.changes/early-panic-for-png-not-rgba.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Early panic if the PNG icon is not RGBA. diff --git a/core/tauri-codegen/src/context.rs b/core/tauri-codegen/src/context.rs index 1ff45f205137..3f739008c654 100644 --- a/core/tauri-codegen/src/context.rs +++ b/core/tauri-codegen/src/context.rs @@ -516,6 +516,13 @@ fn png_icon>( 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 = Vec::new(); while let Ok(Some(row)) = reader.next_row() { buffer.extend(row.data());