From 56c05e04afb204fe30e94e43c5575bed72df63a8 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 22 Sep 2008 19:42:35 +0000 Subject: [PATCH] Actually only allow bytes per row > 0 or B_ANY_BYTES_PER_ROW. Still we don't actually handle other invalid bpr values like if the width doesn't really fit into the provided bytes per row for example. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27696 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Bitmap.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/Bitmap.cpp b/src/kits/interface/Bitmap.cpp index a5b09509bc..dd275c6eca 100644 --- a/src/kits/interface/Bitmap.cpp +++ b/src/kits/interface/Bitmap.cpp @@ -626,8 +626,12 @@ BBitmap::ImportBits(const void *data, int32 length, int32 bpr, int32 offset, return B_BAD_VALUE; int32 width = fBounds.IntegerWidth() + 1; - if (bpr < 0) - bpr = get_bytes_per_row(colorSpace, width); + if (bpr <= 0) { + if (bpr == B_ANY_BYTES_PER_ROW) + bpr = get_bytes_per_row(colorSpace, width); + else + return B_BAD_VALUE; + } return BPrivate::ConvertBits(data, (uint8*)fBasePointer + offset, length, fSize - offset, bpr, fBytesPerRow, colorSpace, fColorSpace, width, @@ -669,8 +673,12 @@ BBitmap::ImportBits(const void *data, int32 length, int32 bpr, if (!data || length < 0 || width < 0 || height < 0) return B_BAD_VALUE; - if (bpr < 0) - bpr = get_bytes_per_row(colorSpace, fBounds.IntegerWidth() + 1); + if (bpr <= 0) { + if (bpr == B_ANY_BYTES_PER_ROW) + bpr = get_bytes_per_row(colorSpace, fBounds.IntegerWidth() + 1); + else + return B_BAD_VALUE; + } return BPrivate::ConvertBits(data, fBasePointer, length, fSize, bpr, fBytesPerRow, colorSpace, fColorSpace, from, to, width, height);