mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-22 05:59:58 +00:00
python/audit2allow: close file stream on error
sepolgen-ifgen-attr-helper.c: In function ‘load_policy’: sepolgen-ifgen-attr-helper.c:196:17: warning: leak of FILE ‘fp’ [CWE-775] [-Wanalyzer-file-leak] 196 | fprintf(stderr, "Out of memory!\n"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
c760a2bff6
commit
c14a86af9a
@ -194,12 +194,14 @@ static policydb_t *load_policy(const char *filename)
|
||||
policydb = malloc(sizeof(policydb_t));
|
||||
if (policydb == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (policydb_init(policydb)) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
free(policydb);
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -208,6 +210,7 @@ static policydb_t *load_policy(const char *filename)
|
||||
fprintf(stderr,
|
||||
"error(s) encountered while parsing configuration\n");
|
||||
free(policydb);
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user