Fixed memory leak in vfs_free_handle().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-03-06 13:08:21 +03:00
parent 407d1f38f5
commit f547d149ba
1 changed files with 9 additions and 6 deletions

View File

@ -178,13 +178,16 @@ vfs_info (int handle)
static void
vfs_free_handle (int handle)
{
if (handle < VFS_FIRST_HANDLE ||
(guint)(handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
return;
const int idx = handle - VFS_FIRST_HANDLE;
g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE) =
(void *) vfs_free_handle_list;
vfs_free_handle_list = handle - VFS_FIRST_HANDLE;
if (handle >= VFS_FIRST_HANDLE && (guint) idx < vfs_openfiles->len) {
struct vfs_openfile *h;
h = (struct vfs_openfile *) g_ptr_array_index (vfs_openfiles, idx);
g_free (h);
g_ptr_array_index (vfs_openfiles, idx) = (void *) vfs_free_handle_list;
vfs_free_handle_list = idx;
}
}
static struct vfs_class *vfs_list;