@matheusbsbs / matheus-bagliano / commits / 0aa0c2b2ec
Fork 0

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 <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mike Hommey committed Nov 22, 2019 at 17:37 UTC 0aa0c2b2ec12c91a122aec7a8497fe3577529eba
1 file changed +16
revision.c
+16
@@ -3201,10 +3201,26 @@ static void compute_indegrees_to_depth(struct rev_info *revs,
3201 indegree_walk_step(revs);
3202 }
3203
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 +
3217 static void init_topo_walk(struct rev_info *revs)
3218 {
3219 struct topo_walk_info *info;
3220 struct commit_list *list;
3221 + if (revs->topo_walk_info)
3222 + reset_topo_walk(revs);
3223 +
3224 revs->topo_walk_info = xmalloc(sizeof(struct topo_walk_info));
3225 info = revs->topo_walk_info;
3226 memset(info, 0, sizeof(struct topo_walk_info));