Bugfixes for vfs



Hi,

I just discovered some memory leaks that I have introduced myself. May I commit them?

Roland
Index: vfs/extfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/extfs.c,v
retrieving revision 1.108
diff -u -r1.108 extfs.c
--- vfs/extfs.c	16 Aug 2004 23:18:42 -0000	1.108
+++ vfs/extfs.c	24 Aug 2004 15:15:59 -0000
@@ -937,17 +937,21 @@
     struct entry *entry;
     struct inode *inode;
     char *path2 = g_strdup(path);
+    int result = -1;
 
     if ((q = extfs_get_path_mangle (path2, &archive, 0, 0)) == NULL)
-	return -1;
+        goto cleanup;
     entry = extfs_find_entry (archive->root_entry, q, 0, 0);
     if (entry == NULL)
-    	return -1;
+        goto cleanup;
     if (resolve && (entry = extfs_resolve_symlinks (entry)) == NULL)
-	return -1;
+        goto cleanup;
     inode = entry->inode;
     extfs_stat_move( buf, inode );
-    return 0;
+    result = 0;
+cleanup:
+    g_free (path2);
+    return result;
 }
 
 static int extfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
@@ -1032,6 +1036,7 @@
     }
     if (extfs_cmd (" rm ", archive, entry, "")){
         my_errno = EIO;
+        goto cleanup;
     }
     extfs_remove_entry (entry);
     result = 0;
Index: vfs/ftpfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/ftpfs.c,v
retrieving revision 1.164
diff -u -r1.164 ftpfs.c
--- vfs/ftpfs.c	17 Aug 2004 11:17:02 -0000	1.164
+++ vfs/ftpfs.c	24 Aug 2004 15:15:59 -0000
@@ -1460,8 +1460,11 @@
     vfs_stamp_create (&vfs_ftpfs_ops, super);
     if (flags & OPT_IGNORE_ERROR)
 	r = COMPLETE;
-    if (r != COMPLETE)
-	    ERRNOR (EPERM, -1);
+    if (r != COMPLETE) {
+        me->verrno = EPERM;
+        g_free (mpath);
+        return -1;
+    }
     if (flush_directory_cache)
 	vfs_s_invalidate(me, super);
     g_free(mpath);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]