Tracker: Fix memory leak in IconCache::SetIcon.

How often this would have occurred before thumbnail support I'm not sure,
but at least now that we have thumbnails, the icons are changed out
with not insignificant frequency, especially on read-only filesystems.
This commit is contained in:
Augustin Cavalier 2022-04-26 15:03:01 -04:00
parent a64cdd1dcc
commit a173592b40

View File

@ -292,18 +292,24 @@ void
IconCacheEntry::SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size,
bool /*create*/)
{
BBitmap** icon = NULL;
if (mode == kNormalIcon) {
if (size == B_MINI_ICON)
fMiniIcon = bitmap;
icon = &fMiniIcon;
else
fLargeIcon = bitmap;
icon = &fLargeIcon;
} else if (mode == kSelectedIcon) {
if (size == B_MINI_ICON)
fHighlightedMiniIcon = bitmap;
icon = &fHighlightedMiniIcon;
else
fHighlightedLargeIcon = bitmap;
} else
icon = &fHighlightedLargeIcon;
}
if (icon == NULL)
TRESPASS();
if ((*icon) != NULL)
delete *icon;
*icon = bitmap;
}