Ticket #7736: 0001-Fix-7736.-Avoid-memory-corruption.patch

File 0001-Fix-7736.-Avoid-memory-corruption.patch, 2.2 KB (added by Janus, 11 years ago)
  • src/apps/showimage/ShowImageView.cpp

    From 38185987b5d1f8152f0e234314517ce7a471fd31 Mon Sep 17 00:00:00 2001
    From: Janus <janus2@ymail.com>
    Date: Fri, 30 Nov 2012 22:21:33 +0000
    Subject: [PATCH] Fix #7736. Avoid memory corruption
    
    ---
     src/apps/showimage/ShowImageView.cpp |   11 +++++++----
     src/apps/showimage/ShowImageView.h   |    3 ++-
     2 files changed, 9 insertions(+), 5 deletions(-)
    
    diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp
    index e6d9a70..d82d3c8 100644
    a b ShowImageView::SetImage(const BMessage* message)  
    347347        || message->FindRef("ref", &ref) != B_OK || bitmap == NULL)
    348348        return B_ERROR;
    349349
    350     status_t status = SetImage(&ref, bitmap);
     350    BitmapOwner* bitmapOwner;
     351    message->FindPointer("bitmapOwner", (void**)&bitmapOwner);
     352
     353    status_t status = SetImage(&ref, bitmap, bitmapOwner);
    351354    if (status == B_OK) {
    352355        fFormatDescription = message->FindString("type");
    353356        fMimeType = message->FindString("mime");
    354 
    355         message->FindPointer("bitmapOwner", (void**)&fBitmapOwner);
    356357    }
    357358
    358359    return status;
    ShowImageView::SetImage(const BMessage* message)  
    360361
    361362
    362363status_t
    363 ShowImageView::SetImage(const entry_ref* ref, BBitmap* bitmap)
     364ShowImageView::SetImage(const entry_ref* ref, BBitmap* bitmap,
     365        BitmapOwner* bitmapOwner)
    364366{
    365367    // Delete the old one, and clear everything
    366368    fUndo.Clear();
    ShowImageView::SetImage(const entry_ref* ref, BBitmap* bitmap)  
    369371    _DeleteBitmap();
    370372
    371373    fBitmap = bitmap;
     374    fBitmapOwner = bitmapOwner;
    372375    if (ref == NULL)
    373376        fCurrentRef.device = -1;
    374377    else
  • src/apps/showimage/ShowImageView.h

    diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h
    index b14985b..bdf4d10 100644
    a b public:  
    5252            void                SetTrackerMessenger(
    5353                                    const BMessenger& trackerMessenger);
    5454            status_t            SetImage(const BMessage* message);
    55             status_t            SetImage(const entry_ref* ref, BBitmap* bitmap);
     55            status_t            SetImage(const entry_ref* ref, BBitmap* bitmap,
     56                                    BitmapOwner* bitmapOwner);
    5657            const entry_ref*    Image() const { return &fCurrentRef; }
    5758            BBitmap*            Bitmap();
    5859