[nautilus/wip/antoniof/meets-valgrind: 10/12] application: Don't leak container array
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/meets-valgrind: 10/12] application: Don't leak container array
- Date: Tue, 22 Dec 2020 15:33:31 +0000 (UTC)
commit d08470f185f3482748b944f34126de4f495e08d7
Author: António Fernandes <antoniof gnome org>
Date: Sat Dec 19 12:00:04 2020 +0000
application: Don't leak container array
We extract an array constant strings from a GVariant dict using the
"^a&s" format string, which is equivalent to g_variant_get_strv() [0]
g_variant_get_srtv() is "(transfer container)", meaning the caller
owns the array.
However, we don't free the array, resulting in a memory leak. [2]
Use autocleanup to fix the leak.
[0]
https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-convenience
[1] https://developer.gnome.org/glib/stable/glib-GVariant.html#g-variant-get-strv
src/nautilus-application.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 10478da9c..a034b3c8b 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -938,7 +938,7 @@ nautilus_application_handle_file_args (NautilusApplication *self,
GFile **files;
GFile *file;
gint idx, len;
- const gchar * const *remaining = NULL;
+ g_autofree const gchar * const *remaining = NULL;
GPtrArray *file_array;
g_variant_dict_lookup (options, G_OPTION_REMAINING, "^a&s", &remaining);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]