Ticket #2058 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

Memoty leak in _vfs_get_cwd() function

Reported by: vit_r Owned by: andrew_b
Priority: critical Milestone: 4.7.1
Component: mc-vfs Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: Votes for changeset: committed-master committed-stable


aligned lines help to see it easier


2058-lib-vfs-mc-vfs-vfs.c-_vfs_get_cwd-missing-g_free.patch (758 bytes) - added by vit_r 12 years ago.

Change History

comment:1 Changed 12 years ago by andrew_b

  • Status changed from new to accepted
  • Owner set to andrew_b
  • Milestone changed from 4.7 to 4.7.1
  • severity changed from no branch to on review
  • Summary changed from lib-vfs-mc-vfs-vfs.c-_vfs_get_cwd-missing-g_free to Memoty leak in _vfs_get_cwd() function

Thanks! But you found one of two memory leaks in _vfs_get_cwd() function.

Created 2058_vfs_memleaks branch. Parent branch is master.

comment:2 Changed 12 years ago by slavazanko

  • Votes for changeset set to slavazanko

comment:3 Changed 12 years ago by angel_il

  • Votes for changeset changed from slavazanko to slavazanko angel_il
  • severity changed from on review to approved

comment:4 follow-up: ↓ 6 Changed 12 years ago by andrew_b

  • Status changed from accepted to testing
  • Votes for changeset changed from slavazanko angel_il to commited-master commited-stable
  • Resolution set to fixed
  • severity changed from approved to merged

comment:5 Changed 12 years ago by andrew_b

  • Status changed from testing to closed

comment:6 in reply to: ↑ 4 Changed 12 years ago by vit_r

Replying to andrew_b:

Merged to master,

i'm really nose up now (so is _vfs_get_cwd() also) Thanks

And if You'll have time ...

at the moment there are two weak funcs (wanted to be rewritten)

load_mc_home_file (...) is extra twisted and has mistakes


#define    g_ptr_array_index(array,index_) ((array)->pdata)[index_]


static long vfs_free_handle_list = -1;

static int
vfs_new_handle (struct vfs_class *vclass, void *fsinfo)
    struct vfs_openfile *h;

    h = g_new (struct vfs_openfile, 1);
    h->fsinfo = fsinfo;
    h->vclass = vclass;

    /* Allocate the first free handle */
    h->handle = vfs_free_handle_list;
    if (h->handle == -1) {
        /* No free allocated handles, allocate one */
        h->handle = vfs_openfiles->len;
        g_ptr_array_add (vfs_openfiles, h);
    } else {
        vfs_free_handle_list = (long) g_ptr_array_index (vfs_openfiles, vfs_free_handle_list);
        g_ptr_array_index (vfs_openfiles, h->handle) = h;

    h->handle += VFS_FIRST_HANDLE;
    return h->handle;

vfs_free_handle_list starts as 'static long vfs_free_handle_list = -1;'

vfs_free_handle_list after g_ptr_array_add (vfs_openfiles, h);


0 == vfs_free_handle_list

but after

vfs_free_handle_list = (long) g_ptr_array_index (...)

becomes again

(-1) == vfs_free_handle_list

Note: See TracTickets for help on using tickets.