Changeset cdb07b55d30df5aefda222f6e9f5099e6f5d8fd9

Show
Ignore:
Timestamp:
05/09/08 22:59:27 (4 months ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1210366767 +0200
git-parent:

[3ad6ea967fe0ae37c01b6883599319e7ee37c0fc]

git-author:
Rafaël Carré <funman@videolan.org> 1210366745 +0200
Message:

Fix memory leaks in ncurses intf

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/ncurses.c

    rf772183 rcdb07b5  
    316316    { 
    317317        p_sys->psz_current_dir = strdup( val.psz_string ); 
    318         free( val.psz_string ); 
    319318    } 
    320319    else 
     
    322321        p_sys->psz_current_dir = strdup( p_intf->p_libvlc->psz_homedir ); 
    323322    } 
     323 
     324    free( val.psz_string ); 
    324325 
    325326    p_sys->i_dir_entries = 0; 
     
    338339    intf_thread_t *p_intf = (intf_thread_t *)p_this; 
    339340    intf_sys_t    *p_sys = p_intf->p_sys; 
    340     int i; 
    341341 
    342342    PlaylistDestroy( p_intf ); 
    343343 
    344     for( i = 0; i < p_sys->i_dir_entries; i++
    345     { 
    346         struct dir_entry_t *p_dir_entry = p_sys->pp_dir_entries[i]; 
     344    while( p_sys->i_dir_entries
     345    { 
     346        struct dir_entry_t *p_dir_entry = p_sys->pp_dir_entries[0]; 
    347347        free( p_dir_entry->psz_path ); 
    348         REMOVE_ELEM( p_sys->pp_dir_entries, p_sys->i_dir_entries, i ); 
     348        REMOVE_ELEM( p_sys->pp_dir_entries, p_sys->i_dir_entries, 0 ); 
    349349        free( p_dir_entry ); 
    350350    } 
     
    13371337    int      i_len; 
    13381338 
     1339    if( w <= 0 ) 
     1340        return; 
     1341 
    13391342    va_start( vl_args, p_fmt ); 
    13401343    if( vasprintf( &p_buf, p_fmt, vl_args ) == -1 ) 
    13411344        return; 
    13421345    va_end( vl_args ); 
    1343  
    1344     if( ( p_buf == NULL ) || ( w <= 0 ) ) 
    1345         return; 
    13461346 
    13471347    i_len = strlen( p_buf ); 
     
    13561356 
    13571357    if( i_char_len == (size_t)-1 ) 
    1358         /* an invalid character was encountered */ 
     1358    /* an invalid character was encountered */ 
     1359    { 
     1360        free( p_buf ); 
    13591361        return; 
     1362    } 
    13601363    else 
    13611364    { 
     
    14241427        mvhline( y, x + i_width, ' ', w - i_width ); 
    14251428    } 
     1429 
     1430    free( p_buf ); 
    14261431#else 
    14271432    if( i_len > w ) 
     
    21302135 
    21312136        DrawBox( p_sys->w, y++, 0, h, COLS, psz_title, p_sys->b_color ); 
     2137        free( psz_title ); 
    21322138 
    21332139        if( p_sys->b_need_update || p_sys->pp_plist == NULL ) 
     
    23842390{ 
    23852391    intf_sys_t *p_sys = p_intf->p_sys; 
    2386     int i; 
    2387  
    2388     for( i = 0; i < p_sys->i_plist_entries; i++ ) 
    2389     { 
    2390         struct pl_item_t *p_pl_item = p_sys->pp_plist[i]; 
     2392 
     2393    while( p_sys->i_plist_entries ) 
     2394    { 
     2395        struct pl_item_t *p_pl_item = p_sys->pp_plist[0]; 
    23912396        free( p_pl_item->psz_display ); 
    2392         REMOVE_ELEM( p_sys->pp_plist, p_sys->i_plist_entries, i ); 
     2397        REMOVE_ELEM( p_sys->pp_plist, p_sys->i_plist_entries, 0 ); 
    23932398        free( p_pl_item ); 
    23942399    } 
    23952400    p_sys->pp_plist = NULL; 
    2396     p_sys->i_plist_entries = 0; 
    23972401} 
    23982402