Ticket #3458: mc-3458-fix-memleak-dir_copy.patch

File mc-3458-fix-memleak-dir_copy.patch, 880 bytes (added by and, 10 years ago)
  • src/filemanager/dir.c

    fix for bug #3439 was not complete, further dir_copy list handling
    
    1. handling dir_copy list as full copy for avoid double free situations
    2. dir_list_init must always have a dir_list_clean() before
    
    found by LeakSanitizer
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    
    a b  
    721721        dfentry = &dir_copy.list[i]; 
    722722 
    723723        dfentry->fnamelen = fentry->fnamelen; 
    724         dfentry->fname = fentry->fname; 
     724        dfentry->fname = g_strndup (fentry->fname, fentry->fnamelen); 
    725725        dfentry->f.marked = fentry->f.marked; 
    726726        dfentry->f.dir_size_computed = fentry->f.dir_size_computed; 
    727727        dfentry->f.link_to_dir = fentry->f.link_to_dir; 
     
    748748    } 
    749749    else 
    750750    { 
     751        dir_list_clean (list); 
    751752        if (!dir_list_init (list)) 
    752753        { 
    753754            dir_list_clean (&dir_copy);