mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
src/vfs/undelfs/undelfs.c: fix memory leaks.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
3feb3f26d6
commit
6cbb11673c
@ -342,13 +342,16 @@ undelfs_loaddel (void)
|
|||||||
static void *
|
static void *
|
||||||
undelfs_opendir (const vfs_path_t * vpath)
|
undelfs_opendir (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
char *file, *f;
|
char *file, *f = NULL;
|
||||||
const vfs_path_element_t *path_element;
|
const vfs_path_element_t *path_element;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
path_element = vfs_path_get_by_index (vpath, -1);
|
||||||
undelfs_get_path (vpath, &file, &f);
|
undelfs_get_path (vpath, &file, &f);
|
||||||
if (!file)
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
g_free (f);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* We don't use the file name */
|
/* We don't use the file name */
|
||||||
g_free (f);
|
g_free (f);
|
||||||
@ -437,7 +440,7 @@ undelfs_closedir (void *vfs_info)
|
|||||||
static void *
|
static void *
|
||||||
undelfs_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
undelfs_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
char *file, *f;
|
char *file, *f = NULL;
|
||||||
ext2_ino_t inode, i;
|
ext2_ino_t inode, i;
|
||||||
undelfs_file *p = NULL;
|
undelfs_file *p = NULL;
|
||||||
(void) flags;
|
(void) flags;
|
||||||
@ -445,8 +448,11 @@ undelfs_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
|
|
||||||
/* Only allow reads on this file system */
|
/* Only allow reads on this file system */
|
||||||
undelfs_get_path (vpath, &file, &f);
|
undelfs_get_path (vpath, &file, &f);
|
||||||
if (!file)
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
g_free (f);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ext2_fname || strcmp (ext2_fname, file))
|
if (!ext2_fname || strcmp (ext2_fname, file))
|
||||||
{
|
{
|
||||||
@ -645,11 +651,14 @@ static int
|
|||||||
undelfs_lstat (const vfs_path_t * vpath, struct stat *buf)
|
undelfs_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||||
{
|
{
|
||||||
int inode_index;
|
int inode_index;
|
||||||
char *file, *f;
|
char *file, *f = NULL;
|
||||||
|
|
||||||
undelfs_get_path (vpath, &file, &f);
|
undelfs_get_path (vpath, &file, &f);
|
||||||
if (!file)
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
g_free (f);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* When called from save_cwd_stats we get an incorrect file and f here:
|
/* When called from save_cwd_stats we get an incorrect file and f here:
|
||||||
e.g. incorrect correct
|
e.g. incorrect correct
|
||||||
@ -696,12 +705,15 @@ undelfs_fstat (void *vfs_info, struct stat *buf)
|
|||||||
static int
|
static int
|
||||||
undelfs_chdir (const vfs_path_t * vpath)
|
undelfs_chdir (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
char *file, *f;
|
char *file, *f = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
undelfs_get_path (vpath, &file, &f);
|
undelfs_get_path (vpath, &file, &f);
|
||||||
if (!file)
|
if (file == NULL)
|
||||||
return -1;
|
{
|
||||||
|
g_free (f);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
/* We may use access because ext2 file systems are local */
|
/* We may use access because ext2 file systems are local */
|
||||||
/* this could be fixed by making an ext2fs io manager to use */
|
/* this could be fixed by making an ext2fs io manager to use */
|
||||||
@ -738,15 +750,16 @@ undelfs_lseek (void *vfs_info, off_t offset, int whence)
|
|||||||
static vfsid
|
static vfsid
|
||||||
undelfs_getid (const vfs_path_t * vpath)
|
undelfs_getid (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
char *fname, *fsname;
|
char *fname = NULL, *fsname;
|
||||||
|
gboolean ok;
|
||||||
|
|
||||||
undelfs_get_path (vpath, &fsname, &fname);
|
undelfs_get_path (vpath, &fsname, &fname);
|
||||||
|
ok = fsname != NULL;
|
||||||
|
|
||||||
if (!fsname)
|
|
||||||
return NULL;
|
|
||||||
g_free (fname);
|
g_free (fname);
|
||||||
g_free (fsname);
|
g_free (fsname);
|
||||||
return (vfsid) fs;
|
|
||||||
|
return ok ? (vfsid) fs : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user