util/foz: stop crashing on destroy if prepare hasn't been called

Fixes: eca6bb9540 ("util/fossilize_db: add basic fossilize db util to read/write shader caches")

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11931>
(cherry picked from commit 2850db0a9e)
This commit is contained in:
Mike Blumenkrantz 2021-07-16 12:50:21 -04:00 committed by Dylan Baker
parent 3c5987e2b4
commit 742c35d17c
2 changed files with 3 additions and 2 deletions

View file

@ -841,7 +841,7 @@
"description": "util/foz: stop crashing on destroy if prepare hasn't been called",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "eca6bb9540d8d1b260511cd0a71bdddb00ff4a3c"
},

View file

@ -334,7 +334,8 @@ foz_prepare(struct foz_db *foz_db, char *cache_path)
void
foz_destroy(struct foz_db *foz_db)
{
fclose(foz_db->db_idx);
if (foz_db->db_idx)
fclose(foz_db->db_idx);
for (unsigned i = 0; i < FOZ_MAX_DBS; i++) {
if (foz_db->file[i])
fclose(foz_db->file[i]);