Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2022-06-16 02:35:42 +0300
committerJunio C Hamano <gitster@pobox.com>2022-06-16 23:22:03 +0300
commit652891de4ff164d545daa5472ab67f4f9d41319b (patch)
treee3fda800a7388b7a8022cc97b49bf041592fcb2c /read-cache.c
parent41a86b64c093a6f36ffe0959aeed2e3f2590c7e8 (diff)
read_index_from(): avoid memory leak
In 998330ac2e7c (read-cache: look for shared index files next to the index, too, 2021-08-26), we added code that allocates memory to store the base path of a shared index, but we never released that memory. Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/read-cache.c b/read-cache.c
index e61af3a3d4..76f372ff91 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2473,15 +2473,15 @@ int read_index_from(struct index_state *istate, const char *path,
the_repository, "%s", base_path);
if (!ret) {
char *path_copy = xstrdup(path);
- const char *base_path2 = xstrfmt("%s/sharedindex.%s",
- dirname(path_copy),
- base_oid_hex);
+ char *base_path2 = xstrfmt("%s/sharedindex.%s",
+ dirname(path_copy), base_oid_hex);
free(path_copy);
trace2_region_enter_printf("index", "shared/do_read_index",
the_repository, "%s", base_path2);
ret = do_read_index(split_index->base, base_path2, 1);
trace2_region_leave_printf("index", "shared/do_read_index",
the_repository, "%s", base_path2);
+ free(base_path2);
}
if (!oideq(&split_index->base_oid, &split_index->base->oid))
die(_("broken index, expect %s in %s, got %s"),