[systemd-devel] [PATCH 3/6] localectl: fix memleak, use _cleanup_strv_free_

Michal Sekletar msekleta at redhat.com
Thu Oct 25 07:16:16 PDT 2012


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.
---
 src/locale/localectl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 16700fe..2f0f6ee 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;
+        char **i;
 
         keymaps = set_new(string_hash_func, string_compare_func);
         if (!keymaps)
-- 
1.7.11.7



More information about the systemd-devel mailing list