From 8f88fe1d98ea0e1118ad247593a6812fd9b4b4fc Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Wed, 18 Aug 2010 19:55:51 +0000 Subject: [PATCH] * fix CID-258: BView::SetViewOverlay() shouldn't crash if given a NULL bitmap. Coverity was complaining because we did a half-ass check against NULL only to pass that NULL pointer on to a function that deref'd it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38248 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 5dad10d39d..0c7c960370 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -3674,7 +3674,7 @@ status_t BView::SetViewOverlay(const BBitmap* overlay, BRect srcRect, BRect dstRect, rgb_color* colorKey, uint32 followFlags, uint32 options) { - if ((overlay->fFlags & B_BITMAP_WILL_OVERLAY) == 0) + if (overlay == NULL || (overlay->fFlags & B_BITMAP_WILL_OVERLAY) == 0) return B_BAD_VALUE; status_t status = _SetViewBitmap(overlay, srcRect, dstRect, followFlags, @@ -3692,11 +3692,11 @@ status_t BView::SetViewOverlay(const BBitmap* overlay, rgb_color* colorKey, uint32 followFlags, uint32 options) { - BRect rect; - if (overlay != NULL) { - rect = overlay->Bounds(); - rect.OffsetTo(B_ORIGIN); - } + if (overlay == NULL) + return B_BAD_VALUE; + + BRect rect = overlay->Bounds(); + rect.OffsetTo(B_ORIGIN); return SetViewOverlay(overlay, rect, rect, colorKey, followFlags, options); }