From 2b8a980240a1c771552b5cab72f35ffe8163f407 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 24 Jun 2024 13:03:45 -0700 Subject: [PATCH] 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 Part-of: --- src/util/fossilize_db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/fossilize_db.c b/src/util/fossilize_db.c index df2d3a1d284..28d9688e0bb 100644 --- a/src/util/fossilize_db.c +++ b/src/util/fossilize_db.c @@ -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))