diff options
author | Jeff King <peff@peff.net> | 2014-08-23 01:27:41 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-08-25 12:20:24 -0700 |
commit | 3c078b9c860c7c1dbe8782aa1f79877354cbc602 (patch) | |
tree | e20f533d50c8ed956c2cd1ddd181860c47a7a327 /t/t0200/test.c | |
parent | Git 2.0.4 (diff) | |
download | tgif-3c078b9c860c7c1dbe8782aa1f79877354cbc602.tar.xz |
fast-import: clean up pack_data pointer in end_packfile
We have a global pointer pack_data pointing to the current
pack we have open. Inside end_packfile we have two new
pointers, old_p and new_p. The latter points to pack_data,
and the former points to the new "installed" version of the
packfile we get when we hand the file off to the regular
sha1_file machinery. When then free old_p.
Presumably the extra old_p pointer was there so that we
could overwrite pack_data with new_p and still free old_p,
but we don't do that. We just leave pack_data pointing to
bogus memory, and don't overwrite it until we call
start_packfile again (if ever).
This can cause problems for our die routine, which calls
end_packfile to clean things up. If we die at the wrong
moment, we can end up looking at invalid memory in
pack_data left after the last end_packfile().
Instead, let's make sure we set pack_data to NULL after we
free it, and make calling endfile() again with a NULL
pack_data a noop (there is nothing to end).
We can further make things less confusing by dropping old_p
entirely, and moving new_p closer to its point of use.
Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0200/test.c')
0 files changed, 0 insertions, 0 deletions