From: Junio C Hamano Date: Fri, 9 Aug 2019 17:13:13 +0000 (-0700) Subject: Merge branch 'ds/commit-graph-incremental' X-Git-Tag: v2.23.0-rc2~4 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/203cf46fac096185701e50cdbf972ba6a67a10c8?ds=inline;hp=-c Merge branch 'ds/commit-graph-incremental' Leakfix. * ds/commit-graph-incremental: commit-graph: release strbufs after use --- 203cf46fac096185701e50cdbf972ba6a67a10c8 diff --combined commit-graph.c index 90fdee9256,fa0760c430..fe954ab5f8 --- a/commit-graph.c +++ b/commit-graph.c @@@ -297,10 -297,8 +297,10 @@@ struct commit_graph *parse_commit_graph hashcpy(graph->oid.hash, graph->data + graph->data_len - graph->hash_len); - if (verify_commit_graph_lite(graph)) + if (verify_commit_graph_lite(graph)) { + free(graph); return NULL; + } return graph; } @@@ -434,6 -432,7 +434,7 @@@ static struct commit_graph *load_commit free(oids); fclose(fp); + strbuf_release(&line); return graph_chain; } @@@ -590,11 -589,6 +591,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) @@@ -623,7 -617,7 +624,7 @@@ item->object.parsed = 1; - 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); @@@ -725,7 -719,7 +726,7 @@@ static struct tree *load_tree_for_commi GRAPH_DATA_WIDTH * (c->graph_pos - g->num_commits_in_base); hashcpy(oid.hash, commit_data); - c->maybe_tree = lookup_tree(r, &oid); + set_commit_tree(c, lookup_tree(r, &oid)); return c->maybe_tree; } @@@ -1186,7 -1180,7 +1187,7 @@@ static int fill_oids_from_packs(struct } stop_progress(&ctx->progress); - strbuf_reset(&progress_title); + strbuf_release(&progress_title); strbuf_release(&packname); return 0; @@@ -1636,7 -1630,7 +1637,7 @@@ static void sort_and_scan_merged_commit num_parents++; if (num_parents > 2) - ctx->num_extra_edges += num_parents - 2; + ctx->num_extra_edges += num_parents - 1; } } @@@ -1713,10 -1707,8 +1714,8 @@@ static void expire_commit_graphs(struc strbuf_addstr(&path, "/info/commit-graphs"); dir = opendir(path.buf); - if (!dir) { - strbuf_release(&path); - return; - } + if (!dir) + goto out; strbuf_addch(&path, '/'); dirnamelen = path.len; @@@ -1745,6 -1737,9 +1744,9 @@@ if (!found) unlink(path.buf); } + + out: + strbuf_release(&path); } int write_commit_graph(const char *obj_dir, @@@ -1995,7 -1990,7 +1997,7 @@@ int verify_commit_graph(struct reposito hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i); graph_commit = lookup_commit(r, &cur_oid); - odb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r)); + odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r)); if (parse_commit_internal(odb_commit, 0, 0)) { graph_report(_("failed to parse commit %s from object database for commit-graph"), oid_to_hex(&cur_oid));