]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: free topo_walk_info before creating a new one in init_topo_walk
authorMike Hommey <mh@glandium.org>
Fri, 22 Nov 2019 08:37:04 +0000 (17:37 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Nov 2019 02:48:48 +0000 (11:48 +0900)
init_topo_walk doesn't reuse an existing topo_walk_info, and currently
leaks the one that might exist on the current rev_info if it was already
used for a topo walk beforehand.

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c

index 4827360ed80ac4fddff1f00c1068eba05791f9d7..fb93c993a443e1d20f98b61706889c3c9df643df 100644 (file)
@@ -3201,10 +3201,26 @@ static void compute_indegrees_to_depth(struct rev_info *revs,
                indegree_walk_step(revs);
 }
 
+static void reset_topo_walk(struct rev_info *revs)
+{
+       struct topo_walk_info *info = revs->topo_walk_info;
+
+       clear_prio_queue(&info->explore_queue);
+       clear_prio_queue(&info->indegree_queue);
+       clear_prio_queue(&info->topo_queue);
+       clear_indegree_slab(&info->indegree);
+       clear_author_date_slab(&info->author_date);
+
+       FREE_AND_NULL(revs->topo_walk_info);
+}
+
 static void init_topo_walk(struct rev_info *revs)
 {
        struct topo_walk_info *info;
        struct commit_list *list;
+       if (revs->topo_walk_info)
+               reset_topo_walk(revs);
+
        revs->topo_walk_info = xmalloc(sizeof(struct topo_walk_info));
        info = revs->topo_walk_info;
        memset(info, 0, sizeof(struct topo_walk_info));