author | Junio C Hamano <gitster@pobox.com> | |
Mon, 13 Dec 2010 06:19:00 +0000 (22:19 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 13 Dec 2010 06:31:45 +0000 (22:31 -0800) | ||
commit | 28042dbcd60f3190d25cfeae0bf81d58a16f4771 | |
tree | 8138ba4200c39c7c22ed535c11bcd2cf57029a3b | tree | snapshot |
parent | 4443091d961e91041e64c1675940f0585eeba456 | commit | diff |
get_sha1_oneline: fix lifespan rule of temp_commit_buffer variable
This is trying to free only what we ourselves read (as opposed to what
we borrowed from commit->buffer) but do so lazily only to work around
the fact that the code has many irregular exit points, and doing it right
makes it necessary to call free() from many different places in the loop.
Rewrite the structure of the code inside the loop so that the variable
has to live within a single iteration, ever. This should make the logic
easier to follow as well.
Also we didn't free a temporary commit list we kept to hold the original
set of commits. Free it.
Noticed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This is trying to free only what we ourselves read (as opposed to what
we borrowed from commit->buffer) but do so lazily only to work around
the fact that the code has many irregular exit points, and doing it right
makes it necessary to call free() from many different places in the loop.
Rewrite the structure of the code inside the loop so that the variable
has to live within a single iteration, ever. This should make the logic
easier to follow as well.
Also we didn't free a temporary commit list we kept to hold the original
set of commits. Free it.
Noticed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c | diff | blob | history |