<html><head></head><body>Hi,<br><br>Not sure what the code tries to do here, but you can't switch the instance underneath a player since the involved underlying VLC objects are tied to the original instance.<br><br>This patch seems as wrong as the current code.<br><br><div class="gmail_quote">Le 8 juillet 2020 17:24:44 GMT+02:00, Alexandre Janniaux <ajanni@videolabs.io> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">The media_player instance retains and releases the libvlc instance it's<br>created from. When using a different libvlc instance for media_player<br>and media, it's using the libvlc instance from the media_t object,<br>leading to the release of the wrong libvlc instance, and thus potential<br>use-after-free of one instance and leaks of the other.<br><br>It has been spotted since VLCKit creates a shared libvlc instance and<br>then can create a new libvlc instance in case the VLCMediaPlayer is<br>created with different options, which means that the VLCMediaPlayer and<br>the VLCMedia will be bound to different libvlc instances, triggering the<br>issue described in first paragraph and crashing.<br><br>Refs videolan/VLCKit#189, videolan/VLCKit#116<hr> lib/media_player.c | 2 ++<br> 1 file changed, 2 insertions(+)<br><br>diff --git a/lib/media_player.c b/lib/media_player.c<br>index 9c7a7a76aad..3e8636facea 100644<br>--- a/lib/media_player.c<br>+++ b/lib/media_player.c<br>@@ -914,6 +914,8 @@ void libvlc_media_player_set_media(<br> <br> /* The policy here is to ignore that we were created using a different<br> * libvlc_instance, because we don't really care */<br>+ libvlc_retain(p_md->p_libvlc_instance);<br>+ libvlc_release(p_mi->p_libvlc_instance);<br> p_mi->p_libvlc_instance = p_md->p_libvlc_instance;<br> <br> vlc_player_Unlock(p_mi->player);</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>