Re: [gedit-list] [PATCH] Fix a possible memory leak



Hi Daniel,

	thanks for the patch. However I do not think it is correct: if you look
a couple of lines above you will see the the value of keys[i] is
"stolen" and stored into the hashtable, so we do not want to free the
array and all the string it stores, but just the array itself.

On a general note we prefer that patches are submitted through bugzilla
where they do not get lost and where review discussion can be tracked.

Ciao
	Paolo

On Sun, 2012-02-05 at 10:23 -0500, Daniel Trebbien wrote:
> Use g_strfreev() rather than g_free().
> 
> The GLib documentation for g_key_file_get_keys() states that g_strfreev()
> should be used to free the return value.
> 
> See:  http://www.gtk.org/api/2.6/glib/glib-Key-value-file-parser.html#g-key-file-get-keys
>       http://developer.gnome.org/glib/stable/glib-Key-value-file-parser.html#g-key-file-get-keys
> ---
>  plugins/modelines/modeline-parser.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/plugins/modelines/modeline-parser.c b/plugins/modelines/modeline-parser.c
> index a4d15a8..20fddb4 100644
> --- a/plugins/modelines/modeline-parser.c
> +++ b/plugins/modelines/modeline-parser.c
> @@ -127,7 +127,7 @@ load_language_mappings_group (GKeyFile *key_file, const gchar *group)
>  		gchar *id = g_key_file_get_string (key_file, group, name, NULL);
>  		g_hash_table_insert (table, name, id);
>  	}
> -	g_free (keys);
> +	g_strfreev (keys);
>  
>  	return table;
>  }




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