Skip to content

Commit 0aa0c2b

Browse files
glandiumgitster
authored andcommitted
revision: free topo_walk_info before creating a new one in init_topo_walk
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ffa1f28 commit 0aa0c2b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

revision.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,10 +3201,26 @@ static void compute_indegrees_to_depth(struct rev_info *revs,
32013201
indegree_walk_step(revs);
32023202
}
32033203

3204+
static void reset_topo_walk(struct rev_info *revs)
3205+
{
3206+
struct topo_walk_info *info = revs->topo_walk_info;
3207+
3208+
clear_prio_queue(&info->explore_queue);
3209+
clear_prio_queue(&info->indegree_queue);
3210+
clear_prio_queue(&info->topo_queue);
3211+
clear_indegree_slab(&info->indegree);
3212+
clear_author_date_slab(&info->author_date);
3213+
3214+
FREE_AND_NULL(revs->topo_walk_info);
3215+
}
3216+
32043217
static void init_topo_walk(struct rev_info *revs)
32053218
{
32063219
struct topo_walk_info *info;
32073220
struct commit_list *list;
3221+
if (revs->topo_walk_info)
3222+
reset_topo_walk(revs);
3223+
32083224
revs->topo_walk_info = xmalloc(sizeof(struct topo_walk_info));
32093225
info = revs->topo_walk_info;
32103226
memset(info, 0, sizeof(struct topo_walk_info));

0 commit comments

Comments
 (0)