mirror of
https://github.com/MidnightCommander/mc
synced 2025-02-22 18:24:23 +03:00
Fixed memory leaks in folowing functions:
* mc_opendir() * mc_chdir() * vfs_release_path() * check_panel_timestamp() Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
60123b7c99
commit
5fa1070225
@ -272,6 +272,7 @@ vfs_release_path (const char *dir)
|
||||
path_element = vfs_path_get_by_index (vpath, -1);
|
||||
|
||||
vfs_stamp_create (path_element->class, vfs_getid (vpath));
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -451,6 +451,7 @@ mc_opendir (const char *dirname)
|
||||
if (info == NULL)
|
||||
{
|
||||
errno = path_element->class->opendir ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||
vfs_path_free (vpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -462,10 +463,11 @@ mc_opendir (const char *dirname)
|
||||
if (path_element->dir.converter == INVALID_CONV)
|
||||
path_element->dir.converter = str_cnv_from_term;
|
||||
|
||||
handle = vfs_new_handle (path_element->class, path_element);
|
||||
handle = vfs_new_handle (path_element->class, vfs_path_element_clone (path_element));
|
||||
|
||||
handlep = g_new (int, 1);
|
||||
*handlep = handle;
|
||||
vfs_path_free (vpath);
|
||||
return (DIR *) handlep;
|
||||
}
|
||||
|
||||
@ -726,6 +728,7 @@ mc_chdir (const char *path)
|
||||
if (result == -1)
|
||||
{
|
||||
errno = vfs_ferrno (path_element->class);
|
||||
vfs_path_free (vpath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -713,6 +713,8 @@ vfs_path_element_clone (const vfs_path_element_t * element)
|
||||
new_element->host = g_strdup (element->host);
|
||||
new_element->path = g_strdup (element->path);
|
||||
new_element->encoding = g_strdup (element->encoding);
|
||||
if (vfs_path_element_need_cleanup_converter (element) && new_element->encoding != NULL)
|
||||
new_element->dir.converter = str_crt_conv_from (new_element->encoding);
|
||||
new_element->vfs_prefix = g_strdup (element->vfs_prefix);
|
||||
|
||||
return new_element;
|
||||
|
@ -481,10 +481,17 @@ check_panel_timestamp (const WPanel * panel, panel_view_mode_t mode, struct vfs_
|
||||
path_element = vfs_path_get_by_index (vpath, -1);
|
||||
|
||||
if (path_element->class != vclass)
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (vfs_getid (vpath) != id)
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
return FALSE;
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user