]> git.sesse.net Git - vlc/commitdiff
* fixed a number of memleaks
authorDerk-Jan Hartman <hartman@videolan.org>
Thu, 6 May 2004 23:14:23 +0000 (23:14 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Thu, 6 May 2004 23:14:23 +0000 (23:14 +0000)
modules/access/directory.c
modules/gui/macosx/controls.m
modules/gui/macosx/playlist.m
modules/gui/macosx/playlistinfo.m
src/input/input.c

index 39c36637d65968e3f6353cd11d73ce631fb36ceb..6598eb096e5a2f0eb9e20f33d22ce4dbb96939a2 100644 (file)
@@ -198,11 +198,12 @@ static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
     msg_Dbg( p_input, "opening directory `%s'", psz_name );
     if( ReadDir( p_playlist, psz_name , i_mode, &i_pos ) != VLC_SUCCESS )
     {
-        free( psz_name );
         goto end;
     }
 
 end:
+    if( psz_name ) free( psz_name );
+    if( psz_mode ) free( psz_mode );
     vlc_object_release( p_playlist );
     p_input->b_eof = 1;
     return 0;
index a368b01f523b8851ca00e4eb79eed0d8c448e53a..242c84b10e97c99a54bb953ee12e74b9d8c19183 100644 (file)
         return;
     }
 
-    if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
+    if( val.psz_string ) free( val.psz_string );
     if( text.psz_string ) free( text.psz_string );
 }
 
             if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
                 [o_lmi setState: TRUE ];
 
+            free( another_val.psz_string );
+
             break;
 
         case VLC_VAR_INTEGER:
     }
     
     /* clean up everything */
-    if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
+    if( val.psz_string ) free( val.psz_string );
     var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
 }
 
index cfcd11d1003c323edd4a6f6539d8c1f3b6e422c4..3799073f2bc539ece850cc7909ea3eca17c4b280 100644 (file)
@@ -496,13 +496,15 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 
     do
     {
+        char *psz_temp;
         i_current++;
 
         vlc_mutex_lock( &p_playlist->object_lock );
         o_current_name = [NSString stringWithUTF8String:
             p_playlist->pp_items[i_current]->input.psz_name];
-        o_current_author = [NSString stringWithUTF8String:
-            playlist_GetInfo(p_playlist, i_current ,_("General"),_("Author") )];
+        psz_temp = playlist_GetInfo(p_playlist, i_current ,_("General"),_("Author") );
+        o_current_author = [NSString stringWithUTF8String: psz_temp];
+        free( psz_temp);
         vlc_mutex_unlock( &p_playlist->object_lock );
 
 
@@ -876,13 +878,24 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     }
     else if( [[o_tc identifier] isEqualToString:@"2"] )
     {
+        char *psz_temp;
         vlc_mutex_lock( &p_playlist->object_lock );
-        o_value = [NSString stringWithUTF8String:
-            playlist_GetInfo(p_playlist, i_row ,_("General"),_("Author") )];
-        if( o_value == NULL )
-            o_value = [NSString stringWithCString:
-                playlist_GetInfo(p_playlist, i_row ,_("General"),_("Author") )];
+        psz_temp = playlist_GetInfo( p_playlist, i_row ,_("General"),_("Author") );
         vlc_mutex_unlock( &p_playlist->object_lock );
+
+        if( psz_temp == NULL )
+        {
+            o_value = @"";
+        }
+        else
+        {
+            o_value = [NSString stringWithUTF8String: psz_temp];
+            if( o_value == NULL )
+            {
+                o_value = [NSString stringWithCString: psz_temp];
+            }
+            free( psz_temp );
+        }
     }
     else if( [[o_tc identifier] isEqualToString:@"3"] )
     {
index 95c3fe59ce6b6614072a100da30e722df72b0d04..6eef87724655156446c0f2e1b94edc9fcb602fc0 100644 (file)
                                           FIND_ANYWHERE );
 
 
-    if (p_playlist)
+    if( p_playlist )
     {
+        char *psz_temp;
+
         /*fill uri / title / author info */
         [o_uri_txt setStringValue:
             ([NSString stringWithUTF8String:p_playlist->
             [NSString stringWithUTF8String:p_playlist->
                 pp_items[i_item]->input.psz_name]];
 
-        [o_author_txt setStringValue:
-            [NSString stringWithUTF8String:playlist_GetInfo
-            (p_playlist, i_item ,_("General"),_("Author") )]];
+        psz_temp = playlist_GetInfo( p_playlist, i_item ,_("General"),_("Author") );
+        [o_author_txt setStringValue: [NSString stringWithUTF8String: psz_temp]];
+        free( psz_temp );
 
         [[VLCInfoTreeItem rootItem] refresh];
         [o_outline_view reloadData];
index 01fdc2f8be893985ac2aafddd551b5f72907f0b4..5061e33cf248919203c3dfd110a271a97b9e4d3b 100644 (file)
@@ -1122,6 +1122,7 @@ static int InitThread( input_thread_t * p_input )
             free( *tmp2++ );
         }
         free( tmp );
+        free( val1.psz_string );
     }
     if( psz_sub_file ) free( psz_sub_file );