Ticket #10865: 0001-MythMusic-Fix-an-abort-due-to-accessing-free-d-memor.patch

File 0001-MythMusic-Fix-an-abort-due-to-accessing-free-d-memor.patch, 2.7 KB (added by Lawrence Rust <lvr@…>, 12 years ago)
  • mythplugins/mythmusic/mythmusic/playlist.cpp

    From 3573a2c431d29848148dedfdbf99d3bc65e2f2b3 Mon Sep 17 00:00:00 2001
    From: Lawrence Rust <lvr@softsystem.co.uk>
    Date: Tue, 26 Jun 2012 15:49:09 +0200
    Subject: [PATCH] MythMusic: Fix an abort due to accessing free'd memory
    
    When creating. editing or deleting a playlist an abort can occur
    in Track::deleteYourWidget by accessing my_widget if it has been deleted
    by its parent.
    
    This patch adds a callback to Track::WidgetDeleted when the widget
    is deleted and so prevents stale data.
    
    Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
    ---
     mythplugins/mythmusic/mythmusic/playlist.cpp      |    6 ++++++
     mythplugins/mythmusic/mythmusic/playlist.h        |    1 +
     mythplugins/mythmusic/mythmusic/treecheckitem.cpp |    6 ++++++
     mythplugins/mythmusic/mythmusic/treecheckitem.h   |    1 +
     4 files changed, 14 insertions(+), 0 deletions(-)
    
    diff --git a/mythplugins/mythmusic/mythmusic/playlist.cpp b/mythplugins/mythmusic/mythmusic/playlist.cpp
    index e2e8dde..0dccc26 100644
    a b void Track::deleteYourWidget() 
    7777    }
    7878}
    7979
     80void Track::WidgetDeleted()
     81{
     82    my_widget = NULL;
     83}
     84
     85
    8086void Track::moveUpDown(bool flag)
    8187{
    8288    parent->moveTrackUpDown(flag, this);
  • mythplugins/mythmusic/mythmusic/playlist.h

    diff --git a/mythplugins/mythmusic/mythmusic/playlist.h b/mythplugins/mythmusic/mythmusic/playlist.h
    index 8b3c3a3..a8c0ca2 100644
    a b class Track 
    5959    int  getValue(){return index_value;}
    6060
    6161    void deleteYourWidget();
     62    void WidgetDeleted();
    6263    void deleteYourself();
    6364    void moveUpDown(bool flag);
    6465
  • mythplugins/mythmusic/mythmusic/treecheckitem.cpp

    diff --git a/mythplugins/mythmusic/mythmusic/treecheckitem.cpp b/mythplugins/mythmusic/mythmusic/treecheckitem.cpp
    index 085abea..46b902d 100644
    a b PlaylistTrack::PlaylistTrack(UIListGenericTree *parent, const QString &title) 
    193193        m_image = pixmap;
    194194}
    195195
     196PlaylistTrack::~PlaylistTrack()
     197{
     198    if (ptr_to_owner)
     199        ptr_to_owner->WidgetDeleted();
     200}
     201
    196202void PlaylistTrack::userSelectedMe(void)
    197203{
    198204}
  • mythplugins/mythmusic/mythmusic/treecheckitem.h

    diff --git a/mythplugins/mythmusic/mythmusic/treecheckitem.h b/mythplugins/mythmusic/mythmusic/treecheckitem.h
    index fad1535..a9060e8 100644
    a b class PlaylistTrack : public PlaylistItem 
    7272{
    7373  public:
    7474    PlaylistTrack(UIListGenericTree *parent, const QString &title);
     75    virtual ~PlaylistTrack();
    7576
    7677    void setOwner(Track *owner);
    7778    void userSelectedMe();