libselinux: getconlist: free memory on multiple level arguments

Do not leak memory if the program argument `l` got passed more than
once.

Found by clang-analyzer.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
Christian Göttsche 2021-05-03 17:10:55 +02:00 committed by Petr Lautrbach
parent d0c02882b7
commit d0e16077d4

View File

@ -26,6 +26,7 @@ int main(int argc, char **argv)
while ((opt = getopt(argc, argv, "l:")) > 0) {
switch (opt) {
case 'l':
free(level);
level = strdup(optarg);
if (!level) {
fprintf(stderr, "memory allocation failure: %d(%s)\n",