commit 6dcdad080328627983a3d6f2234e195d67feff8f from: Stefan Sperling date: Sun Nov 18 20:45:31 2018 UTC plug memory leaks in advance_branch() commit - e20293f22c3b2a1b5215653937598f272b1ce627 commit + 6dcdad080328627983a3d6f2234e195d67feff8f blob - 7ca2aa5795d839cb3b05074a245a575fa5bc069d blob + f1b2429b1df1def03a126f6ab25fd1e1f5d9694b --- lib/commit_graph.c +++ lib/commit_graph.c @@ -294,7 +294,7 @@ advance_branch(struct got_commit_graph *graph, * which do not contribute any content to this path. */ if (is_merge_point(node) && !got_path_is_root_dir(graph->path)) { - struct got_object_id *id, *merged_id, *prev_id = NULL; + struct got_object_id *merged_id, *prev_id = NULL; int branches_differ = 0; err = got_object_id_by_path(&merged_id, repo, commit_id, @@ -303,6 +303,8 @@ advance_branch(struct got_commit_graph *graph, return err; SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) { + struct got_object_id *id; + if (got_object_idset_get(graph->node_ids, qid->id)) continue; /* parent already traversed */ @@ -313,6 +315,8 @@ advance_branch(struct got_commit_graph *graph, branches_differ = 1; continue; } + free(merged_id); + free(prev_id); return err; } @@ -320,8 +324,9 @@ advance_branch(struct got_commit_graph *graph, if (!branches_differ && got_object_id_cmp(merged_id, prev_id) != 0) branches_differ = 1; - } else - prev_id = id; + free(prev_id); + } + prev_id = id; /* * If a branch has created the merged content we can @@ -330,9 +335,16 @@ advance_branch(struct got_commit_graph *graph, if (got_object_id_cmp(merged_id, id) == 0) { err = got_object_idset_add(graph->open_branches, qid->id, node); + free(merged_id); + free(id); return err; } } + + free(prev_id); + prev_id = NULL; + free(merged_id); + merged_id = NULL; /* * If the path's content is the same on all branches,