From 9c1fb53d2a77c8691ecf3a319ebdf72eeba8e4ff Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Thu, 23 Nov 2023 14:14:48 +0000 Subject: [PATCH] [PTRun]Check we're not trying to get an icon with an empty filename (#29990) --- .../Wox.Infrastructure/Image/WindowsThumbnailProvider.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/launcher/Wox.Infrastructure/Image/WindowsThumbnailProvider.cs b/src/modules/launcher/Wox.Infrastructure/Image/WindowsThumbnailProvider.cs index 4dd9481678..af64306df5 100644 --- a/src/modules/launcher/Wox.Infrastructure/Image/WindowsThumbnailProvider.cs +++ b/src/modules/launcher/Wox.Infrastructure/Image/WindowsThumbnailProvider.cs @@ -83,13 +83,17 @@ namespace Wox.Infrastructure.Image public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options) { IntPtr hBitmap = IntPtr.Zero; + string targetLinkedFilePath = string.Empty; if (Path.GetExtension(fileName).Equals(".lnk", StringComparison.OrdinalIgnoreCase)) { // If the file has a '.lnk' extension, it is a shortcut file. Use the shellLinkHelper to retrieve the actual target file path from the shortcut. IShellLinkHelper shellLinkHelper = new ShellLinkHelper(); + targetLinkedFilePath = shellLinkHelper.RetrieveTargetPath(fileName); + } - string targetFilePath = shellLinkHelper.RetrieveTargetPath(fileName); - hBitmap = ExtractIconToHBitmap(targetFilePath); + if (!string.IsNullOrEmpty(targetLinkedFilePath)) + { + hBitmap = ExtractIconToHBitmap(targetLinkedFilePath); } else {