From caff7156466e7f0f9a25efa464d9198aae705668 Mon Sep 17 00:00:00 2001 From: meowtec Date: Fri, 26 May 2023 12:34:59 +0800 Subject: [PATCH] feat(core): early panic if the PNG icon is not RGBA, closes #6706 --- .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..ace15393da86 --- /dev/null +++ b/.changes/early-panic-for-png-not-rgba.md @@ -0,0 +1,5 @@ +--- +"tauri-codegen": 'patch:enhance' +--- + +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..c2929320c2e1 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());