author | Jonathan Nieder <jrnieder@gmail.com> | |
Sun, 14 Aug 2011 15:22:04 +0000 (10:22 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 16 Aug 2011 17:51:34 +0000 (10:51 -0700) | ||
commit | 127f04522292fc62152762405c92d6acca4dbcb5 | |
tree | 799a8c1b30f8032e1e7e00c4358ee4c7c8d7b52c | tree | snapshot |
parent | 86c7bb47c76948bd1240a0db5b8dd88cf9db855d | commit | diff |
revert: plug memory leak in "cherry-pick root commit" codepath
The empty tree passed as common ancestor to merge_trees() when
cherry-picking a parentless commit is allocated on the heap and never
freed. Leaking such a small one-time allocation is not a very big
problem, but now that "git cherry-pick" can cherry-pick multiple
commits it can start to add up.
Avoid the leak by storing the fake tree exactly once in the BSS
section (i.e., use a static). While at it, let's add a test to make
sure cherry-picking multiple parentless commits continues to work.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The empty tree passed as common ancestor to merge_trees() when
cherry-picking a parentless commit is allocated on the heap and never
freed. Leaking such a small one-time allocation is not a very big
problem, but now that "git cherry-pick" can cherry-pick multiple
commits it can start to add up.
Avoid the leak by storing the fake tree exactly once in the BSS
section (i.e., use a static). While at it, let's add a test to make
sure cherry-picking multiple parentless commits continues to work.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/revert.c | diff | blob | history | |
t/t3503-cherry-pick-root.sh | diff | blob | history |