processcontroller: Fix memory leak
When getting icon is failed, get_team_name_and_icon() does not return false, so bitmap allocated to infoPack.team_icon can be leaked. * Delete bitmap in get_team_name_and_icon(), not in caller. * Return false when getiing icon is failed. Change-Id: Ib65065b59b70cd839e6deda4e1142bd104072d84 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3744 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
c1e6e51a05
commit
e5b7c9e313
@ -134,7 +134,6 @@ MemoryBarMenu::Pulse()
|
|||||||
fTeamList[j] = infos.team_info.team;
|
fTeamList[j] = infos.team_info.team;
|
||||||
if (!get_team_name_and_icon(infos, true)) {
|
if (!get_team_name_and_icon(infos, true)) {
|
||||||
// the team is already gone!
|
// the team is already gone!
|
||||||
delete infos.team_icon;
|
|
||||||
fTeamList[j] = -1;
|
fTeamList[j] = -1;
|
||||||
} else {
|
} else {
|
||||||
if (!item && firstRecycle < lastRecycle)
|
if (!item && firstRecycle < lastRecycle)
|
||||||
|
@ -106,10 +106,11 @@ QuitMenu::AddTeam(team_id tmid)
|
|||||||
else {
|
else {
|
||||||
info_pack infos;
|
info_pack infos;
|
||||||
if (get_team_info(tmid, &infos.team_info) == B_OK
|
if (get_team_info(tmid, &infos.team_info) == B_OK
|
||||||
&& get_team_name_and_icon(infos, true))
|
&& get_team_name_and_icon(infos, true)) {
|
||||||
item = new QuitMenuItem(tmid, infos.team_icon, infos.team_name,
|
item = new QuitMenuItem(tmid, infos.team_icon, infos.team_name,
|
||||||
message, true);
|
message, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (item) {
|
if (item) {
|
||||||
item->SetTarget(gPCView);
|
item->SetTarget(gPCView);
|
||||||
AddItem(item);
|
AddItem(item);
|
||||||
|
@ -117,7 +117,6 @@ TeamBarMenu::Pulse()
|
|||||||
fTeamList[j] = infos.team_info.team;
|
fTeamList[j] = infos.team_info.team;
|
||||||
if (!get_team_name_and_icon(infos, true)) {
|
if (!get_team_name_and_icon(infos, true)) {
|
||||||
// the team is already gone!
|
// the team is already gone!
|
||||||
delete infos.team_icon;
|
|
||||||
fTeamList[j] = -1;
|
fTeamList[j] = -1;
|
||||||
} else {
|
} else {
|
||||||
if (!item && firstRecycle < lastRecycle) {
|
if (!item && firstRecycle < lastRecycle) {
|
||||||
|
@ -67,6 +67,12 @@ get_team_name_and_icon(info_pack& infoPack, bool icon)
|
|||||||
B_MINI_ICON) != B_OK) {
|
B_MINI_ICON) != B_OK) {
|
||||||
BMimeType genericAppType(B_APP_MIME_TYPE);
|
BMimeType genericAppType(B_APP_MIME_TYPE);
|
||||||
status = genericAppType.GetIcon(infoPack.team_icon, B_MINI_ICON);
|
status = genericAppType.GetIcon(infoPack.team_icon, B_MINI_ICON);
|
||||||
|
// failed to get icon
|
||||||
|
if (status != B_OK) {
|
||||||
|
delete infoPack.team_icon;
|
||||||
|
infoPack.team_icon = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
infoPack.team_icon = NULL;
|
infoPack.team_icon = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user