This repository was archived by the owner on Nov 9, 2017. It is now read-only.
Commit 1823bea
git_connect: use argv_array
This avoids magic numbers when we allocate fixed-size argv
arrays, and makes it more obvious that we are not
overflowing.
It is also the first step to fixing a memory leak. When
git_connect returns a child_process struct, the argv array
in the struct is dynamically allocated, but the individual
strings are not (they are either owned elsewhere, or are
freed). Later, in finish_connect, we free the array but
leave the strings alone.
This works for the child_process created by git_connect, but
if we use transport_take_over, we may also end up with a
child_process created by transport-helper's get_helper.
In that case, the strings are freshly allocated, and we
would want to free them. However, we have no idea in
finish_connect which type we have.
By consistently using run-command's internal argv-array, we
do not have to worry about this issue at all; finish_command
takes care of it for us, and we can drop our manual free
entirely.
Note that this actually makes the get_helper leak slightly
worse; now we are leaking both the strings and the array.
But when we adjust it in a future patch, that leak will go
away entirely.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 5eb7f7e commit 1823bea
1 file changed
+10
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
537 | | - | |
538 | 537 | | |
539 | 538 | | |
540 | 539 | | |
541 | 540 | | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | 541 | | |
548 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
549 | 545 | | |
550 | 546 | | |
551 | 547 | | |
552 | | - | |
| 548 | + | |
553 | 549 | | |
554 | 550 | | |
555 | 551 | | |
| |||
663 | 659 | | |
664 | 660 | | |
665 | 661 | | |
666 | | - | |
667 | 662 | | |
668 | 663 | | |
669 | 664 | | |
| |||
707 | 702 | | |
708 | 703 | | |
709 | 704 | | |
710 | | - | |
711 | 705 | | |
712 | 706 | | |
713 | 707 | | |
| |||
718 | 712 | | |
719 | 713 | | |
720 | 714 | | |
721 | | - | |
| 715 | + | |
722 | 716 | | |
723 | | - | |
| 717 | + | |
724 | 718 | | |
725 | 719 | | |
726 | | - | |
727 | | - | |
| 720 | + | |
| 721 | + | |
728 | 722 | | |
729 | | - | |
| 723 | + | |
730 | 724 | | |
731 | 725 | | |
732 | 726 | | |
733 | 727 | | |
734 | 728 | | |
735 | | - | |
736 | | - | |
| 729 | + | |
737 | 730 | | |
738 | 731 | | |
739 | 732 | | |
| |||
759 | 752 | | |
760 | 753 | | |
761 | 754 | | |
762 | | - | |
763 | 755 | | |
764 | 756 | | |
765 | 757 | | |
0 commit comments