Skip to content

Commit c14a86a

Browse files
cgzonesjwcart2
authored andcommitted
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 <[email protected]> Acked-by: James Carter <[email protected]>
1 parent c760a2b commit c14a86a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

python/audit2allow/sepolgen-ifgen-attr-helper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,14 @@ static policydb_t *load_policy(const char *filename)
194194
policydb = malloc(sizeof(policydb_t));
195195
if (policydb == NULL) {
196196
fprintf(stderr, "Out of memory!\n");
197+
fclose(fp);
197198
return NULL;
198199
}
199200

200201
if (policydb_init(policydb)) {
201202
fprintf(stderr, "Out of memory!\n");
202203
free(policydb);
204+
fclose(fp);
203205
return NULL;
204206
}
205207

@@ -208,6 +210,7 @@ static policydb_t *load_policy(const char *filename)
208210
fprintf(stderr,
209211
"error(s) encountered while parsing configuration\n");
210212
free(policydb);
213+
fclose(fp);
211214
return NULL;
212215
}
213216

0 commit comments

Comments
 (0)