>From 986e910b03ef6130d34d9d1d998282061a41c148 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Thu, 6 Aug 2015 15:01:14 +0300 Subject: [PATCH] getfacl.c: fix some static analysis issues --- tools/getfacl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/getfacl.c b/tools/getfacl.c index e44b572..9cf7372 100644 --- a/tools/getfacl.c +++ b/tools/getfacl.c @@ -125,7 +125,7 @@ struct name_list *get_list(const struct stat *st, acl_t acl) return NULL; while (ret > 0) { acl_tag_t e_type; - const id_t *id_p; + id_t *id_p = NULL; const char *name = ""; int len; @@ -151,6 +151,8 @@ struct name_list *get_list(const struct stat *st, acl_t acl) name = group_name(*id_p, opt_numeric); break; } + if (id_p != NULL) + acl_free(id_p); name = xquote(name, "\t\n\r"); len = strlen(name); if (last == NULL) { @@ -388,14 +390,26 @@ int do_show(FILE *stream, const char *path_p, const struct stat *st, show_line(stream, &acl_names, acl, &acl_ent, acl_mask, NULL, NULL, NULL, NULL); + if (acl_id_p) + acl_free(acl_id_p); + if (dacl_id_p) + acl_free(dacl_id_p); continue; } else if (dacl && (!acl || *dacl_id_p < *acl_id_p)) { show_line(stream, NULL, NULL, NULL, NULL, &dacl_names, dacl, &dacl_ent, dacl_mask); + if (acl_id_p) + acl_free(acl_id_p); + if (dacl_id_p) + acl_free(dacl_id_p); continue; } + if (acl_id_p) + acl_free(acl_id_p); + if (dacl_id_p) + acl_free(dacl_id_p); } show_line(stream, &acl_names, acl, &acl_ent, acl_mask, &dacl_names, dacl, &dacl_ent, dacl_mask); -- 2.1.0