util/fossilize_db: don't use check_files_opened_successfully for foz_prepare

The check function will free the db or the file if the other is NULL,
however, in this case db and the file are passed to foz_destroy, which
will also free them. This results in a double free. Instead, check that
either is NULL, and then goto the error case to ensure proper cleanup.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29881>
This commit is contained in:
Dylan Baker
2024-06-24 13:03:45 -07:00
committed by Marge Bot
parent 112481d576
commit 2b8a980240
+1 -1
View File
@@ -519,7 +519,7 @@ foz_prepare(struct foz_db *foz_db, char *cache_path)
free(filename);
free(idx_filename);
if (!check_files_opened_successfully(foz_db->file[0], foz_db->db_idx))
if (foz_db->file[0] == NULL || foz_db->db_idx == NULL)
goto fail;
if (!load_foz_dbs(foz_db, foz_db->db_idx, 0, false))