[vlc-devel] commit: macosx controls: Another string memleak. (Derk-Jan Hartman )

git version control git at videolan.org
Thu May 28 15:42:17 CEST 2009


vlc | branch: 1.0-bugfix | Derk-Jan Hartman <hartman at videolan.org> | Thu May 28 14:28:51 2009 +0200| [1692e7000a5639bb70d1d48b761ee40707ddc560] | committer: Derk-Jan Hartman 

macosx controls: Another string memleak.

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

 modules/gui/macosx/controls.m |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m
index a52cff8..0d85e98 100644
--- a/modules/gui/macosx/controls.m
+++ b/modules/gui/macosx/controls.m
@@ -707,7 +707,6 @@
     [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
                                         text.psz_string : psz_variable ]];
 
-    var_Get( p_object, psz_variable, &val );
     if( i_type & VLC_VAR_HASCHOICE )
     {
         NSMenu *o_menu = [o_mi submenu];
@@ -718,6 +717,10 @@
         free( text.psz_string );
         return;
     }
+    if( var_Get( p_object, psz_variable, &val ) < 0 )
+    {
+        return;
+    }
 
     VLCAutoGeneratedMenuContent *o_data;
     switch( i_type & VLC_VAR_TYPE )
@@ -737,8 +740,7 @@
         break;
 
     default:
-        free( text.psz_string );
-        return;
+        break;
     }
 
     if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
@@ -831,7 +833,6 @@
 
     for( i = 0; i < val_list.p_list->i_count; i++ )
     {
-        vlc_value_t another_val;
         NSMenuItem * o_lmi;
         NSString *o_title = @"";
         VLCAutoGeneratedMenuContent *o_data;
@@ -839,15 +840,13 @@
         switch( i_type & VLC_VAR_TYPE )
         {
         case VLC_VAR_STRING:
-            another_val.psz_string =
-                strdup(val_list.p_list->p_values[i].psz_string);
 
             o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
                 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
 
             o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
             o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
-                    andValue: another_val ofType: i_type];
+                    andValue: val_list.p_list->p_values[i] ofType: i_type];
             [o_lmi setRepresentedObject: [o_data autorelease]];
             [o_lmi setTarget: self];
 
@@ -1156,10 +1155,12 @@
 
     if( self != nil )
     {
-        psz_name = strdup( name );
         _vlc_object = vlc_object_hold( object );
-        value = val;
+        psz_name = strdup( name );
         i_type = type;
+        value = val;
+        if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING )
+            value.psz_string = strdup( val.psz_string );
     }
 
     return( self );
@@ -1168,6 +1169,8 @@
 - (void)dealloc
 {
     vlc_object_release( _vlc_object );
+    if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING )
+        free( value.psz_string );
     free( psz_name );
     [super dealloc];
 }




More information about the vlc-devel mailing list