* 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
This commit is contained in:
Oliver Tappe 2010-08-18 19:55:51 +00:00
parent 1c9ed76e33
commit 8f88fe1d98

View File

@ -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);
}