Fix #7736. Avoid memory corruption

Signed-off-by: Axel Dörfler <axeld@pinc-software.de>
This commit is contained in:
Janus 2012-11-30 22:21:33 +00:00 committed by Axel Dörfler
parent 43ee85f69c
commit 03352b04c5
2 changed files with 9 additions and 5 deletions

View File

@ -347,12 +347,13 @@ ShowImageView::SetImage(const BMessage* message)
|| message->FindRef("ref", &ref) != B_OK || bitmap == NULL)
return B_ERROR;
status_t status = SetImage(&ref, bitmap);
BitmapOwner* bitmapOwner;
message->FindPointer("bitmapOwner", (void**)&bitmapOwner);
status_t status = SetImage(&ref, bitmap, bitmapOwner);
if (status == B_OK) {
fFormatDescription = message->FindString("type");
fMimeType = message->FindString("mime");
message->FindPointer("bitmapOwner", (void**)&fBitmapOwner);
}
return status;
@ -360,7 +361,8 @@ ShowImageView::SetImage(const BMessage* message)
status_t
ShowImageView::SetImage(const entry_ref* ref, BBitmap* bitmap)
ShowImageView::SetImage(const entry_ref* ref, BBitmap* bitmap,
BitmapOwner* bitmapOwner)
{
// Delete the old one, and clear everything
fUndo.Clear();
@ -369,6 +371,7 @@ ShowImageView::SetImage(const entry_ref* ref, BBitmap* bitmap)
_DeleteBitmap();
fBitmap = bitmap;
fBitmapOwner = bitmapOwner;
if (ref == NULL)
fCurrentRef.device = -1;
else

View File

@ -52,7 +52,8 @@ public:
void SetTrackerMessenger(
const BMessenger& trackerMessenger);
status_t SetImage(const BMessage* message);
status_t SetImage(const entry_ref* ref, BBitmap* bitmap);
status_t SetImage(const entry_ref* ref, BBitmap* bitmap,
BitmapOwner* bitmapOwner);
const entry_ref* Image() const { return &fCurrentRef; }
BBitmap* Bitmap();