From fe23eed7b6527e77a6e30d291dcfebb6b675126f Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Tue, 29 Jul 2025 13:22:30 +0800 Subject: [PATCH] fix(windows): validate extracted icon content in `convertIconToImage` * Added a check to ensure the extracted icon is not empty or fully transparent. * This prevents issues with displaying icons that do not have valid visual content. --- wox.core/plugin/system/app/app_windows.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wox.core/plugin/system/app/app_windows.go b/wox.core/plugin/system/app/app_windows.go index 3814ace9..3c14ac25 100644 --- a/wox.core/plugin/system/app/app_windows.go +++ b/wox.core/plugin/system/app/app_windows.go @@ -383,6 +383,22 @@ func (a *WindowsRetriever) convertIconToImage(ctx context.Context, hIcon win.HIC } } + // Validate that the image has actual content (not just transparent pixels) + hasContent := false + bounds := img.Bounds() + for y := bounds.Min.Y; y < bounds.Max.Y && !hasContent; y++ { + for x := bounds.Min.X; x < bounds.Max.X && !hasContent; x++ { + r, g, b, a := img.At(x, y).RGBA() + if a > 0 && (r > 0 || g > 0 || b > 0) { + hasContent = true + } + } + } + + if !hasContent { + return nil, fmt.Errorf("extracted icon is empty or fully transparent") + } + return img, nil }