version_policy: avoid fclose a NULL file pointer
Test: Pass a not cil file to version_policy and see no crash appeared. example: out/host/linux-x86/bin/version_policy -b `which ls` -m -n 10000.0 -o target Change-Id: If2b950a02dd94a4813b74377617f90c7a75a9f27 Signed-off-by: liwugang <liwugang@xiaomi.com>
This commit is contained in:
parent
56d34f7838
commit
85ce153283
1 changed files with 3 additions and 2 deletions
|
@ -65,14 +65,15 @@ static int read_cil_file(struct cil_db **db, char *path) {
|
|||
rc = cil_add_file(*db, path, buff, file_size);
|
||||
if (rc != SEPOL_OK) {
|
||||
fprintf(stderr, "Failure adding %s to parse tree\n", path);
|
||||
goto err;
|
||||
goto parse_err;
|
||||
}
|
||||
free(buff);
|
||||
|
||||
return SEPOL_OK;
|
||||
err:
|
||||
free(buff);
|
||||
fclose(file);
|
||||
parse_err:
|
||||
free(buff);
|
||||
file_err:
|
||||
cil_db_destroy(db);
|
||||
return rc;
|
||||
|
|
Loading…
Reference in a new issue