diff options
author | Elijah Newren <newren@gmail.com> | 2018-04-23 23:50:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-02 10:21:28 +0900 |
commit | 7db118303aa04930bea66e855e8659e042f3fa5d (patch) | |
tree | 3beac161fa1e64c599173194f65c14b88d526164 /t/t4026-color.sh | |
parent | Git 2.17 (diff) | |
download | tgif-7db118303aa04930bea66e855e8659e042f3fa5d.tar.xz |
unpack_trees: fix breakage when o->src_index != o->dst_index
Currently, all callers of unpack_trees() set o->src_index == o->dst_index.
The code in unpack_trees() does not correctly handle them being different.
There are two separate issues:
First, there is the possibility of memory corruption. Since
unpack_trees() creates a temporary index in o->result and then discards
o->dst_index and overwrites it with o->result, in the special case that
o->src_index == o->dst_index, it is safe to just reuse o->src_index's
split_index for o->result. However, when src and dst are different,
reusing o->src_index's split_index for o->result will cause the
split_index to be shared. If either index then has entries replaced or
removed, it will result in the other index referring to free()'d memory.
Second, we can drop the index extensions. Previously, we were moving
index extensions from o->dst_index to o->result. Since o->src_index is
the one that will have the necessary extensions (o->dst_index is likely to
be a new index temporary index created to store the results), we should be
moving the index extensions from there.
Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4026-color.sh')
0 files changed, 0 insertions, 0 deletions