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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user