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>
This commit is contained in:
Mike Blumenkrantz 2021-07-16 12:50:21 -04:00 committed by Marge Bot
parent d27f7fa1b3
commit 2850db0a9e

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]);