From: Michal Sekletar Date: Fri, 26 Oct 2012 12:16:18 +0000 (+0200) Subject: localectl: fix memleak, use _cleanup_strv_free_ X-Git-Tag: v196~202 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=7ca7021a9e0c443d40d0af5e9a7e1962d8032229;ds=sidebyside localectl: fix memleak, use _cleanup_strv_free_ l might contain zero strings, however there is still memory allocated for NULL terminator, use _cleanup_strv_free_ instead to prevent tiny leak in such case. --- diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 84feb25d5..7d3ac0ad2 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -483,7 +483,8 @@ static int nftw_cb( } static int list_vconsole_keymaps(DBusConnection *bus, char **args, unsigned n) { - char **l, **i; + char _cleanup_strv_free_ **l = NULL; + char **i; keymaps = set_new(string_hash_func, string_compare_func); if (!keymaps) @@ -513,7 +514,6 @@ static int list_vconsole_keymaps(DBusConnection *bus, char **args, unsigned n) { STRV_FOREACH(i, l) puts(*i); - strv_free(l); return 0; }