<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>The email in which this is a reply to inaccurately states “01/19” in the subject, which was not at all wanted.</p>
<p>The patch should simply be on its own.</p>
<p>Sorry about the inconvenience,<br />
Filip</p>
<p>On 2017-05-18 12:16, Filip Roséen wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> Instead of getting all the dictionary keys, and iterating over them to
 get the associated values, only to free/release the associated data;
 use vlc_dictionary_clear together with a callback to handle the work
 for us.

 These changes also fixes a potential null-pointer dereference if the
 previous usage of vlc_dictionary_all_keys failed.
 ---
  lib/media_discoverer.c | 19 +++++++++----------
  1 file changed, 9 insertions(+), 10 deletions(-)

 diff --git a/lib/media_discoverer.c b/lib/media_discoverer.c
 index 4f1f215062..367d7ea8e8 100644
 --- a/lib/media_discoverer.c
 +++ b/lib/media_discoverer.c
 @@ -243,6 +243,13 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
  /**************************************************************************
   * release (Public)
   **************************************************************************/
 +static void
 +MediaListDictValueRelease( void* mlist, void* obj )
 +{
 +    libvlc_media_list_release( mlist );
 +    (void)obj;
 +}
 +
  void
  libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
  {
 @@ -251,17 +258,9 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )

      libvlc_media_list_release( p_mdis->p_mlist );

 -    /* Free catname_to_submedialist and all the mlist */
 -    char ** all_keys = vlc_dictionary_all_keys( &p_mdis->catname_to_submedialist );
 -    for( int i = 0; all_keys[i]; i++ )
 -    {
 -        libvlc_media_list_t * p_catmlist = vlc_dictionary_value_for_key( &p_mdis->catname_to_submedialist, all_keys[i] );
 -        libvlc_media_list_release( p_catmlist );
 -        free( all_keys[i] );
 -    }
 -    free( all_keys );
 +    vlc_dictionary_clear( &p_mdis->catname_to_submedialist,
 +        MediaListDictValueRelease, NULL );

 -    vlc_dictionary_clear( &p_mdis->catname_to_submedialist, NULL, NULL );
      libvlc_event_manager_destroy( &p_mdis->event_manager );
      libvlc_release( p_mdis->p_libvlc_instance );

 -- 
 2.12.2</code></pre>
</blockquote>
</body>
</html>