aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-05-11 13:56:22 -0700
committerJunio C Hamano <gitster@pobox.com>2022-05-11 13:56:22 -0700
commit4c5d5e1b72cc22446df664007bed533ad2e1efd3 (patch)
tree95162e591c8808aacaccc89010f41cdcf4b85e84
parentMerge branch 'ah/rebase-keep-base-fix' (diff)
parentcommit-graph: close file before returning NULL (diff)
downloadgit-4c5d5e1b72cc22446df664007bed533ad2e1efd3.tar.gz
git-4c5d5e1b72cc22446df664007bed533ad2e1efd3.zip
Merge branch 'kt/commit-graph-plug-fp-leak-on-error'
Fix a leak of FILE * in an error codepath. * kt/commit-graph-plug-fp-leak-on-error: commit-graph: close file before returning NULL
-rw-r--r--commit-graph.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 441b36016b..06107beedc 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -523,10 +523,13 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
stat_res = stat(chain_name, &st);
free(chain_name);
- if (!fp ||
- stat_res ||
- st.st_size <= the_hash_algo->hexsz)
+ if (!fp)
return NULL;
+ if (stat_res ||
+ st.st_size <= the_hash_algo->hexsz) {
+ fclose(fp);
+ return NULL;
+ }
count = st.st_size / (the_hash_algo->hexsz + 1);
CALLOC_ARRAY(oids, count);