[vlc-commits] lib: media_player: keep player libvlc instance
Alexandre Janniaux
git at videolan.org
Tue Jul 14 22:20:43 CEST 2020
vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Thu Jul 9 17:21:50 2020 +0200| [12fa8556c092df472c38ab58517358a71a9d72de] | committer: Alexandre Janniaux
lib: media_player: keep player libvlc instance
The media_player instance retains and releases the libvlc instance it's
created from. When using a different libvlc instance for media_player
and media, it was using the libvlc instance from the media_t object,
leading to the release of the wrong libvlc instance, and thus potential
use-after-free of one instance and leaks of the other.
It has been spotted since VLCKit creates a shared libvlc instance and
then can create a new libvlc instance in case the VLCMediaPlayer is
created with different options, which means that the VLCMediaPlayer and
the VLCMedia will be bound to different libvlc instances, triggering the
issue described in first paragraph and crashing.
/!\ This commit changes libvlc behaviour in the following case:
- There's at least two libvlc instance, one being the parent of a media
and the other being the parent of a media_player.
- The media is set on the media_player.
- A new media is played by the underlying vlc_player_t, in which case
the new libvlc_media_t instance is now created with the player
libvlc instance instead of the media libvlc instance.
- The user call libvlc_media_player_get_media() on the player.
- The user call preparse functions on the media.
Since this very case was leading to crash anyway, and is quite
intricate, it's probably not a very important change though.
Refs videolan/VLCKit#189, videolan/VLCKit#116
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=12fa8556c092df472c38ab58517358a71a9d72de
---
lib/media_player.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/lib/media_player.c b/lib/media_player.c
index 9c7a7a76aa..b00984753e 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -912,10 +912,6 @@ void libvlc_media_player_set_media(
vlc_player_SetCurrentMedia(p_mi->player, p_md->p_input_item);
- /* The policy here is to ignore that we were created using a different
- * libvlc_instance, because we don't really care */
- p_mi->p_libvlc_instance = p_md->p_libvlc_instance;
-
vlc_player_Unlock(p_mi->player);
}
More information about the vlc-commits
mailing list