Fixed CID 1298: In the case that sSelectedIcon is not valid, checkMark could be

leaked. So I reorganized the if statement to remove this possibility.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27431 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood
2008-09-12 05:20:49 +00:00
parent 1594b70bc1
commit 78cc6f918f
+3 -2
View File
@@ -252,9 +252,9 @@ PrinterItem::PrinterItem(PrintersWindow* window, const BDirectory& node)
if (sIcon && sIcon->IsValid() && sSelectedIcon == NULL) { if (sIcon && sIcon->IsValid() && sSelectedIcon == NULL) {
BBitmap *checkMark = LoadBitmap("check_mark_icon", 'BBMP'); BBitmap *checkMark = LoadBitmap("check_mark_icon", 'BBMP');
if (checkMark && checkMark->IsValid()) {
sSelectedIcon = new BBitmap(rect, B_RGBA32, true); sSelectedIcon = new BBitmap(rect, B_RGBA32, true);
if (checkMark && checkMark->IsValid() if (sSelectedIcon && sSelectedIcon->IsValid()) {
&& sSelectedIcon && sSelectedIcon->IsValid()) {
// draw check mark at bottom left over printer icon // draw check mark at bottom left over printer icon
BView *view = new BView(rect, "offscreen", B_FOLLOW_ALL, B_WILL_DRAW); BView *view = new BView(rect, "offscreen", B_FOLLOW_ALL, B_WILL_DRAW);
float y = rect.Height() - checkMark->Bounds().Height(); float y = rect.Height() - checkMark->Bounds().Height();
@@ -267,6 +267,7 @@ PrinterItem::PrinterItem(PrintersWindow* window, const BDirectory& node)
view->RemoveSelf(); view->RemoveSelf();
sSelectedIcon->Unlock(); sSelectedIcon->Unlock();
delete view; delete view;
}
delete checkMark; delete checkMark;
} }
} }