Fix file pointer leak on error path

This commit is contained in:
Wang Han 2025-05-20 19:18:59 +08:00 committed by John Wu
parent 5e050d7456
commit 0e86d4dbcb

View File

@ -250,6 +250,7 @@ bool SePolicy::to_file(::rust::Utf8CStr file) const noexcept {
pf.fp = fp; pf.fp = fp;
if (policydb_write(impl->db, &pf)) { if (policydb_write(impl->db, &pf)) {
LOGE("Fail to create policy image\n"); LOGE("Fail to create policy image\n");
fclose(fp);
return false; return false;
} }
fclose(fp); fclose(fp);