Fix possible double release

This commit is contained in:
Jack251970 2024-12-11 11:08:57 +08:00
parent 49fc0b8fd0
commit 8a05c606e4

View file

@ -62,6 +62,7 @@ namespace Flow.Launcher.Infrastructure.Image
if (nativeShellItem is not IShellItemImageFactory imageFactory) if (nativeShellItem is not IShellItemImageFactory imageFactory)
{ {
Marshal.ReleaseComObject(nativeShellItem); Marshal.ReleaseComObject(nativeShellItem);
nativeShellItem = null;
throw new InvalidOperationException("Failed to get IShellItemImageFactory"); throw new InvalidOperationException("Failed to get IShellItemImageFactory");
} }
@ -86,7 +87,10 @@ namespace Flow.Launcher.Infrastructure.Image
} }
finally finally
{ {
Marshal.ReleaseComObject(nativeShellItem); if (nativeShellItem != null)
{
Marshal.ReleaseComObject(nativeShellItem);
}
} }
return hBitmap; return hBitmap;