[haiku-commits] haiku: hrev50671 - src/kits/media

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 5 Nov 2016 21:24:57 +0100 (CET)

hrev50671 adds 1 changeset to branch 'master'
old head: f4db7fdc68461d7d30abb6ae43fa762917963ce1
new head: 156b6cd596cb7514ff1252731b5da18271b6980f
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=156b6cd596cb+%5Ef4db7fdc6846

----------------------------------------------------------------------------

156b6cd596cb: BMediaFile: fix destruction order.
  
  The fSource can point to a source with code inside a media plug-in (in
  particular, the HTTP source from the http_streamer plugin). However,
  deleting the extractor can cause the plugin to become "unreferenced" and
  unloaded. If we try to call code to delete the source later, we find
  that the code is already unloaded, and the app crashes.
  
  This happens in Web+ when navigating away from Youtube or otherwise
  interrupting a video while it is being played.
  
  Fixes the crashing part of #13058.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev50671
Commit:      156b6cd596cb7514ff1252731b5da18271b6980f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=156b6cd596cb
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sat Nov  5 20:18:39 2016 UTC

Ticket:      https://dev.haiku-os.org/ticket/13058

----------------------------------------------------------------------------

1 file changed, 7 insertions(+), 4 deletions(-)
src/kits/media/MediaFile.cpp | 11 +++++++----

----------------------------------------------------------------------------

diff --git a/src/kits/media/MediaFile.cpp b/src/kits/media/MediaFile.cpp
index 0afae78..12592bd 100644
--- a/src/kits/media/MediaFile.cpp
+++ b/src/kits/media/MediaFile.cpp
@@ -469,15 +469,18 @@ BMediaFile::_UnInit()
        free(fTrackList);
        fTrackList = NULL;
        fTrackNum = 0;
-       delete fExtractor;
-       fExtractor = NULL;
-       delete fWriter;
-       fWriter = NULL;
        if (fDeleteSource) {
                delete fSource;
                fSource = NULL;
                fDeleteSource = false;
        }
+       // Deleting the extractor or writer can cause unloading of the plugins.
+       // The source must be deleted before that, because it can come from a
+       // plugin (for example the http_streamer)
+       delete fExtractor;
+       fExtractor = NULL;
+       delete fWriter;
+       fWriter = NULL;
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev50671 - src/kits/media - pulkomandy