libvlc: fix libvlc_media_slaves_release with a count of 0
authorThomas Guillem <thomas@gllm.fr>
Tue, 31 May 2016 13:13:42 +0000 (15:13 +0200)
committerThomas Guillem <thomas@gllm.fr>
Tue, 31 May 2016 14:23:09 +0000 (16:23 +0200)
Since pp_slaves is not initialised when libvlc_media_slaves_get() returns 0.

lib/media.c

index 1f7db2c..1f7acae 100644 (file)
@@ -1220,8 +1220,11 @@ unsigned int libvlc_media_slaves_get( libvlc_media_t *p_md,
 void libvlc_media_slaves_release( libvlc_media_slave_t **pp_slaves,
                                   unsigned int i_count )
 {
-    assert( pp_slaves );
-    for( unsigned int i = 0; i < i_count; ++i )
-        free(pp_slaves[i]);
-    free(pp_slaves);
+    if( i_count > 0 )
+    {
+        assert( pp_slaves );
+        for( unsigned int i = 0; i < i_count; ++i )
+            free( pp_slaves[i] );
+        free( pp_slaves );
+    }
 }