util/disk_cache: fix crash in fossilize_db

We don't need to close the file here check_files_opened_successfully()
already does that for us if needed.

This fixes a crash when invalid filename/paths are provided to the
MESA_DISK_CACHE_READ_ONLY_FOZ_DBS environment variable.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9251>
This commit is contained in:
Timothy Arceri 2021-02-24 23:27:15 +11:00 committed by Marge Bot
parent ba4bc54dea
commit fbabd2163d

View file

@ -282,10 +282,8 @@ foz_prepare(struct foz_db *foz_db, char *base_filename)
free(filename);
free(idx_filename);
if (!check_files_opened_successfully(foz_db->file[file_idx], db_idx)) {
fclose(db_idx);
if (!check_files_opened_successfully(foz_db->file[file_idx], db_idx))
continue; /* Ignore invalid user provided filename and continue */
}
if (!load_foz_dbs(foz_db, db_idx, file_idx, true)) {
fclose(db_idx);