diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 5de3ef73f..f0204e48a 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,14 @@ +2000-03-31 Andrew V. Samoilov + + * vfs.c (mc_def_getlocalcopy): free() replaced by g_free() to prevent + crushes with mad, thanks to Timur I. Bakeyev + * fish.c (linear_start): name wasn't freed after usage + * cpio.c (cpio_ungetlocalcopy): return type changed to int, + function return 0 now + * direntry.c (vfs_s_close, vfs_s_resolve_symlink): memory, allocated + by vfs_s_fullpath () is freed after use + * ftpfs.c (linear_start): ditto; + 2000-04-03 Pavel Machek * ftpfs.c (send_ftp_command): return from vfs_s_get_path_mangle is diff --git a/vfs/cpio.c b/vfs/cpio.c index 9accc19ad..5881c6cb2 100644 --- a/vfs/cpio.c +++ b/vfs/cpio.c @@ -31,7 +31,7 @@ /* #include "utilvfs.h" */ #include "../src/dialog.h" -//#include "cpio.h" +/* #include "cpio.h" */ #include "names.h" enum { @@ -574,10 +574,11 @@ static int cpio_read(void *fh, char *buffer, int count) return count; } -static void cpio_ungetlocalcopy(vfs *me, char *path, char *local, int has_changed) +static int cpio_ungetlocalcopy(vfs *me, char *path, char *local, int has_changed) { /* We do just nothing. (We are read only and do not need to free local, since it will be freed when tar archive will be freed */ + return 0; } static int cpio_fh_open(vfs *me, vfs_s_fh *fh, int flags, int mode) diff --git a/vfs/direntry.c b/vfs/direntry.c index c38f026b2..ad85f9e0f 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -229,7 +229,6 @@ vfs_s_find_entry_tree (vfs *me, vfs_s_inode *root, char *path, int follow, int f { unsigned int pseg; vfs_s_entry *ent = NULL; - int found; char p[MC_MAXPATHLEN] = ""; while (1){ @@ -248,7 +247,6 @@ vfs_s_find_entry_tree (vfs *me, vfs_s_inode *root, char *path, int follow, int f strncpy (p + (t = strlen (p)), path, pseg); p[t + pseg] = '\0'; - found = 0; for (ent = root->subdir; ent != NULL; ent = ent->next) if (strlen (ent->name) == pseg && (!strncmp (ent->name, path, pseg))) /* FOUND! */ @@ -376,7 +374,9 @@ vfs_s_resolve_symlink (vfs *me, vfs_s_entry *entry, char *path, int follow) if (*linkname == PATH_SEP) return (MEDATA->find_entry) (me, entry->dir->super->root, linkname, follow - 1, 0); else { /* FIXME: this does not work */ - sprintf(buf, "%s/%s", vfs_s_fullpath(me, entry->dir), linkname); + char *fullpath = vfs_s_fullpath(me, entry->dir); + sprintf(buf, "%s/%s", fullpath, linkname); + g_free (fullpath); return (MEDATA->find_entry) (me, entry->dir->super->root, buf, follow - 1, 0); } } @@ -411,10 +411,6 @@ vfs_s_new_super (vfs *me) vfs_s_super *super; super = g_new0 (struct vfs_s_super, 1); - super->root = NULL; - super->name = NULL; - super->fd_usage = 0; - super->ino_usage = 0; super->me = me; return super; } @@ -557,7 +553,7 @@ vfs_s_fullpath (vfs *me, vfs_s_inode *ino) ERRNOR (EAGAIN, NULL); if ((!ino->ent->dir) || (!ino->ent->dir->ent)) /* It must be directory */ - return g_strconcat( ino->ent->name, NULL ); + return g_strdup (ino->ent->name); return g_strconcat (ino->ent->dir->ent->name, PATH_SEP_STR, ino->ent->name, NULL); @@ -917,8 +913,10 @@ vfs_s_close (void *fh) char *s = vfs_s_fullpath (me, FH->ino); if (!s) res = -1; - else + else { res = MEDATA->file_store (me, FH_SUPER, s, FH->ino->localname); + g_free (s); + } vfs_s_invalidate (me, FH_SUPER); } if (FH->handle) diff --git a/vfs/fish.c b/vfs/fish.c index 1f4eeb5a9..6e44ca2e1 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -514,7 +514,7 @@ static int linear_start(vfs *me, vfs_s_fh *fh, int offset) name = vfs_s_fullpath (me, fh->ino); if (!name) return 0; - if (command(me, FH_SUPER, WANT_STRING, + offset = command(me, FH_SUPER, WANT_STRING, "#RETR /%s\n" "ls -l \"/%s\" | (\n" "read var1 var2 var3 var4 var5 var6\n" @@ -523,8 +523,9 @@ static int linear_start(vfs *me, vfs_s_fh *fh, int offset) "echo '### 100'\n" "cat \"/%s\"\n" "echo '### 200'\n", - name, name, name ) - != PRELIM) ERRNOR (E_REMOTE, 0); + name, name, name ); + g_free (name); + if (offset != PRELIM) ERRNOR (E_REMOTE, 0); fh->linear = LS_LINEAR_OPEN; fh->u.fish.got = 0; if (sscanf( reply_str, "%d", &fh->u.fish.total )!=1) diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 347d65009..b410a51fc 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -81,6 +81,7 @@ What to do with this? #include "vfs.h" #include "tcputil.h" #include "../src/dialog.h" +#include "../src/setup.h" /* for load_anon_passwd */ #include "container.h" #include "ftpfs.h" #ifndef MAXHOSTNAMELEN @@ -1368,6 +1369,7 @@ linear_start(vfs *me, vfs_s_fh *fh, int offset) if (!name) return 0; FH_SOCK = open_data_connection(me, FH_SUPER, "RETR", name, TYPE_BINARY, offset); + g_free (name); if (FH_SOCK == -1) ERRNOR (EACCES, 0); fh->linear = LS_LINEAR_OPEN; diff --git a/vfs/vfs.c b/vfs/vfs.c index 786dc81e2..25f6d2c23 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -1093,7 +1093,7 @@ mc_def_getlocalcopy (vfs *vfs, char *filename) fail: if (fdout) close(fdout); if (fdin) mc_close (fdin); - free (tmp); + g_free (tmp); return NULL; }