From: Junio C Hamano Date: Sun, 19 May 2019 07:45:28 +0000 (+0900) Subject: Merge branch 'js/commit-graph-parse-leakfix' X-Git-Tag: v2.22.0-rc1~27 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3c9b393ca8fdb4db53e461a6f506dd10ed6fbc85?hp=-c Merge branch 'js/commit-graph-parse-leakfix' Leakfix. * js/commit-graph-parse-leakfix: commit-graph: fix memory leak --- 3c9b393ca8fdb4db53e461a6f506dd10ed6fbc85 diff --combined commit-graph.c index 7bcc9bb7e0,4bce70d35c..7c5e54875f --- a/commit-graph.c +++ b/commit-graph.c @@@ -267,8 -267,10 +267,10 @@@ struct commit_graph *parse_commit_graph last_chunk_offset = chunk_offset; } - if (verify_commit_graph_lite(graph)) + if (verify_commit_graph_lite(graph)) { + free(graph); return NULL; + } return graph; } @@@ -397,11 -399,6 +399,11 @@@ static void fill_commit_graph_info(stru item->generation = get_be32(commit_data + g->hash_len + 8) >> 2; } +static inline void set_commit_tree(struct commit *c, struct tree *t) +{ + c->maybe_tree = t; +} + static int fill_commit_in_graph(struct repository *r, struct commit *item, struct commit_graph *g, uint32_t pos) @@@ -415,7 -412,7 +417,7 @@@ item->object.parsed = 1; item->graph_pos = pos; - item->maybe_tree = NULL; + set_commit_tree(item, NULL); date_high = get_be32(commit_data + g->hash_len + 8) & 0x3; date_low = get_be32(commit_data + g->hash_len + 12); @@@ -501,7 -498,7 +503,7 @@@ static struct tree *load_tree_for_commi GRAPH_DATA_WIDTH * (c->graph_pos); hashcpy(oid.hash, commit_data); - c->maybe_tree = lookup_tree(r, &oid); + set_commit_tree(c, lookup_tree(r, &oid)); return c->maybe_tree; }