Skip to content

Commit 4067a64

Browse files
derrickstoleegitster
authored andcommitted
commit-reach: fix memory and flag leaks
The can_all_from_reach_with_flag() method uses 'assign_flag' as a value we can use to mark objects temporarily during our commit walk. The intent is that these flags are removed from all objects before returning. However, this is not the case. The 'from' array could also contain objects that are not commits, and we mark those objects with 'assign_flag'. Add a loop to the 'cleanup' section that removes these markers. Also, we forgot to free() the memory for 'list', so add that to the 'cleanup' section. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b67f6b2 commit 4067a64

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

commit-reach.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,11 @@ int can_all_from_reach_with_flag(struct object_array *from,
626626
clear_commit_marks(list[i], RESULT);
627627
clear_commit_marks(list[i], assign_flag);
628628
}
629+
free(list);
630+
631+
for (i = 0; i < from->nr; i++)
632+
from->objects[i].item->flags &= ~assign_flag;
633+
629634
return result;
630635
}
631636

0 commit comments

Comments
 (0)