diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-08-25 12:40:43 +0100 |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-09-05 07:44:15 +0100 |
commit | 8a8c9942ed2f2f98b614747e4bfbae6b29f04d56 (patch) | |
tree | ecede4dec90b9e73b5802240bc75f76fc34cb80e /daemon/gvfsbackendarchive.c | |
parent | cae982f8d6ca03407fb2f189d3e6d1e7ca1d8979 (diff) | |
download | gvfs-8a8c9942ed2f2f98b614747e4bfbae6b29f04d56.tar.gz |
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
Diffstat (limited to 'daemon/gvfsbackendarchive.c')
-rw-r--r-- | daemon/gvfsbackendarchive.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/daemon/gvfsbackendarchive.c b/daemon/gvfsbackendarchive.c index 32c9c5c2..f98ee78a 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); |