[gvfs] archive: Fix some memory leaks
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] archive: Fix some memory leaks
- Date: Fri, 5 Sep 2014 06:44:57 +0000 (UTC)
commit 8a8c9942ed2f2f98b614747e4bfbae6b29f04d56
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Mon Aug 25 12:40:43 2014 +0100
archive: Fix some memory leaks
Unfortunately, the clever trick to avoid string copying causes leaks
because it inserts NULLs in the middle of a NULL-terminated array.
https://bugzilla.gnome.org/show_bug.cgi?id=729463
daemon/gvfsbackendarchive.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/daemon/gvfsbackendarchive.c b/daemon/gvfsbackendarchive.c
index 32c9c5c..f98ee78 100644
--- a/daemon/gvfsbackendarchive.c
+++ b/daemon/gvfsbackendarchive.c
@@ -286,21 +286,17 @@ archive_file_get_from_path (ArchiveFile *file, const char *filename, gboolean ad
if (cur == NULL && add != FALSE)
{
DEBUG ("adding node %s to %s\n", names[i], file->name);
- /* (hopefully) clever trick to avoid string copy */
if (names[i][0] != 0 &&
strcmp (names[i], ".") != 0)
{
cur = g_slice_new0 (ArchiveFile);
- cur->name = names[i];
- names[i] = NULL;
+ cur->name = g_strdup (names[i]);
file->children = g_slist_prepend (file->children, cur);
}
else
{
/* Ignore empty elements from directories ending with a slash.
* Ignore elements consisting of a single "." */
- g_free (names[i]);
- names[i] = NULL;
cur = file;
}
}
@@ -646,6 +642,7 @@ do_mount (GVfsBackend *backend,
filename = g_file_get_uri (archive->file);
DEBUG ("mounted %s\n", filename);
s = g_uri_escape_string (filename, NULL, FALSE);
+ g_free (filename);
mount_spec = g_mount_spec_new ("archive");
g_mount_spec_set (mount_spec, "host", s);
g_free (s);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]