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.
This commit is contained in:
Adrien Destugues
2016-11-05 21:18:39 +01:00
parent f4db7fdc68
commit 156b6cd596
+7 -4
View File
@@ -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;
}