[vlc-devel] commit: Fix memleak (same problem with var_Change(VLC_VAR_FREELIST)). ( Rémi Duraffort )

git version control git at videolan.org
Wed May 20 11:05:20 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Duraffort <ivoire at videolan.org> | Wed May 20 11:03:10 2009 +0200| [27edb261330215efd4889c88ab7facc13d020a86] | committer: Rémi Duraffort 

Fix memleak (same problem with var_Change(VLC_VAR_FREELIST)).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27edb261330215efd4889c88ab7facc13d020a86
---

 src/control/audio.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/control/audio.c b/src/control/audio.c
index e7a912f..59b02c9 100644
--- a/src/control/audio.c
+++ b/src/control/audio.c
@@ -441,13 +441,13 @@ int libvlc_audio_get_track( libvlc_media_player_t *p_mi,
     var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
     for( i = 0; i < val_list.p_list->i_count; i++ )
     {
-        vlc_value_t track_val = val_list.p_list->p_values[i];
-        if( track_val.i_int == val.i_int )
+        if( val_list.p_list->p_values[i].i_int == val.i_int )
         {
             i_track = i;
             break;
-       }
+        }
     }
+    var_Change( p_input_thread, "audio-es", VLC_VAR_FREELIST, &val_list, NULL );
     vlc_object_release( p_input_thread );
     return i_track;
 }
@@ -470,16 +470,16 @@ void libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track,
     if( (i_track < 0) && (i_track > val_list.p_list->i_count) )
     {
         libvlc_exception_raise( p_e, "Audio track out of range" );
-        vlc_object_release( p_input_thread );
-        return;
+        goto end;
     }
 
     newval = val_list.p_list->p_values[i_track];
     i_ret = var_Set( p_input_thread, "audio-es", newval );
     if( i_ret < 0 )
-    {
         libvlc_exception_raise( p_e, "Setting audio track failed" );
-    }
+
+end:
+    var_Change( p_input_thread, "audio-es", VLC_VAR_FREELIST, &val_list, NULL );
     vlc_object_release( p_input_thread );
 }
 




More information about the vlc-devel mailing list