util/fossilize_db: Fix double free in error handling.

If the file ptr is not NULL then foz_destroy will also try to destroy it.

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/14671>
This commit is contained in:
Bas Nieuwenhuizen 2022-01-23 23:43:49 +01:00 committed by Marge Bot
parent 4198ca4b3f
commit 51416b1a12
1 changed files with 5 additions and 1 deletions

View File

@ -318,8 +318,12 @@ foz_prepare(struct foz_db *foz_db, char *cache_path)
free(filename);
free(idx_filename);
if (!check_files_opened_successfully(foz_db->file[file_idx], db_idx))
if (!check_files_opened_successfully(foz_db->file[file_idx], db_idx)) {
/* Prevent foz_destroy from destroying it a second time. */
foz_db->file[file_idx] = NULL;
continue; /* Ignore invalid user provided filename and continue */
}
if (!load_foz_dbs(foz_db, db_idx, file_idx, true)) {
fclose(db_idx);