nix-config/assets/ironbar-fix-tray-crash.patch

26 lines
869 B
Diff
Raw Normal View History

From 2bc741d197867cd5f0c391b9532b4cf9c4d378f6 Mon Sep 17 00:00:00 2001
From: Jake Stanger <mail@jstanger.dev>
Date: Sun, 4 Aug 2024 13:38:29 +0100
Subject: [PATCH] fix(tray): crash when provided empty pixmap
Fixes #675
---
src/modules/tray/icon.rs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/modules/tray/icon.rs b/src/modules/tray/icon.rs
index c42ff4a5..87a77e50 100644
--- a/src/modules/tray/icon.rs
+++ b/src/modules/tray/icon.rs
@@ -90,6 +90,10 @@ fn get_image_from_pixmap(item: &TrayMenu, size: u32) -> Result<Image> {
.and_then(|pixmap| pixmap.first())
.ok_or_else(|| Report::msg("Failed to get pixmap from tray icon"))?;
+ if pixmap.width == 0 || pixmap.height == 0 {
+ return Err(Report::msg("empty pixmap"));
+ }
+
let mut pixels = pixmap.pixels.to_vec();
for i in (0..pixels.len()).step_by(4) {