mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-25 23:42:05 +00:00
libselinux: fix memory leak in getconlist
In getconlist.c's main(), "level" is duplicated from an optional argument without being ever freed. clang's static analyzer warns about this memory leak. Free the allocated memory properly in order to remove a warning reported by clang's static analyzer. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
c56bb631c4
commit
5f76f6b8fb
@ -40,6 +40,7 @@ int main(int argc, char **argv)
|
||||
if (!is_selinux_enabled()) {
|
||||
fprintf(stderr,
|
||||
"getconlist may be used only on a SELinux kernel.\n");
|
||||
free(level);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -49,6 +50,7 @@ int main(int argc, char **argv)
|
||||
if (((argc - optind) < 2)) {
|
||||
if (getcon(&cur_context) < 0) {
|
||||
fprintf(stderr, "Couldn't get current context.\n");
|
||||
free(level);
|
||||
return 2;
|
||||
}
|
||||
} else
|
||||
@ -68,6 +70,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
free(usercon);
|
||||
free(level);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user