mirror of
https://github.com/topjohnwu/selinux.git
synced 2024-12-03 09:00:51 +00:00
libsepol/cil: silence static analyser's use-after-free warning
clang's static analyze reports a use-after-free in __cil_expr_to_string(), when __cil_expr_to_string_helper() does not modify its third parameter (variable s1 here) in this loop: for (curr = curr->next; curr; curr = curr->next) { __cil_expr_to_string_helper(curr, flavor, &s1); cil_asprintf(&c2, "%s %s", c1, s1); free(c1); free(s1); c1 = c2; } Silence this warning by making sure s1 is always NULL at the beginning of every iteration of the loop. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
5d59284381
commit
913613da66
@ -2075,6 +2075,7 @@ static void __cil_expr_to_string(struct cil_list *expr, enum cil_flavor flavor,
|
||||
char *c2 = NULL;
|
||||
__cil_expr_to_string_helper(curr, flavor, &c1);
|
||||
for (curr = curr->next; curr; curr = curr->next) {
|
||||
s1 = NULL;
|
||||
__cil_expr_to_string_helper(curr, flavor, &s1);
|
||||
cil_asprintf(&c2, "%s %s", c1, s1);
|
||||
free(c1);
|
||||
|
Loading…
Reference in New Issue
Block a user