Re: extfs.c extfs_internal_stat: g_free(path2)?
- From: "Andrew V. Samoilov" <andrew email zp ua>
- To: Leonard den Ottolander <leonard den ottolander nl>
- Cc: mc-devel gnome org
- Subject: Re: extfs.c extfs_internal_stat: g_free(path2)?
- Date: Sun, 22 Aug 2004 15:53:19 +0300 (EEST)
Hi, Leonard!
>
> Shouldn't path2 be g_freed in extfs_internal_stat?
You are right. Patch attached.
--
Regards,
Andrew V. Samoilov.
vfs/ChangeLog:
* extfs.c (extfs_internal_stat): Fix memory leak. Reported by
Leonard den Ottolander <leonard den ottolander nl>.
--- mc/vfs/extfs.c~ Tue Aug 17 12:50:10 2004
+++ mc/vfs/extfs.c Sun Aug 22 15:41:26 2004
@@ -933,20 +933,22 @@ static void extfs_stat_move( struct stat
static int extfs_internal_stat (const char *path, struct stat *buf, int resolve)
{
struct archive *archive;
- char *q;
+ char *q, *path_copy = g_strdup (path); /* q may point inside the path_copy */
struct entry *entry;
- struct inode *inode;
- char *path2 = g_strdup(path);
- if ((q = extfs_get_path_mangle (path2, &archive, 0, 0)) == NULL)
+ if ((q = extfs_get_path_mangle (path_copy, &archive, 0, 0)) == NULL) {
+ g_free (path_copy);
return -1;
+ }
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
- if (entry == NULL)
+ if (entry == NULL) {
+ g_free (path_copy);
return -1;
+ }
+ g_free (path_copy);
if (resolve && (entry = extfs_resolve_symlinks (entry)) == NULL)
return -1;
- inode = entry->inode;
- extfs_stat_move( buf, inode );
+ extfs_stat_move (buf, entry->inode);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]