[haiku-development] object on the hype, using it as parameter and then use delete

  • From: Fredrik Modéen <fredrik@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 12 Sep 2008 13:56:21 +0200 (CEST)

I'm going to show my lack of knowledge here :)

Coverty reports a RESOURCE_LEAK (CID 868)
in filetypes/IconView.cpp.

If i'm going to follow Coverty suggestion I would put a delete(mini); at
the end of MessageReceived, but wouldn't that destroy a object that
perhaps are in use? perhaps that's what FALSE in Coverty are for :)

this are how it's setup to work, it's only part of it but it showas what
i'm talkning about.

void
IconView::MessageReceived(BMessage* message)
{
BBitmap *mini = NULL;
if (message->FindMessage("icon/mini", &archive) == B_OK)
  mini = (BBitmap*)BBitmap::Instantiate(&archive);

if (mini != NULL)
 _SetIcon(mini);
}

void
IconView::_SetIcon(BBitmap* mini)
{
 BAppFileInfo info();
 if (mini != NULL || force)
  info.SetIconForType(fType.Type(), mini, B_MINI_ICON);
}

-- 
MVH
Fredrik Modéen


Other related posts: