mirror of
https://github.com/git/git.git
synced 2026-01-27 10:58:50 +00:00
Avoid a segmentation fault with renaming merges
Under very particular circumstances, merge-recursive's `add_cacheinfo()` function gets a `NULL` returned from `refresh_cache_entry()` without expecting it, and subsequently passes it to `add_cache_entry()` which consequently crashes. Let's not crash. This fixes https://github.com/git-for-windows/git/issues/952 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -235,7 +235,7 @@ static int add_cacheinfo(struct merge_options *o,
|
||||
struct cache_entry *nce;
|
||||
|
||||
nce = refresh_cache_entry(ce, CE_MATCH_REFRESH | CE_MATCH_IGNORE_MISSING);
|
||||
if (nce != ce)
|
||||
if (nce && nce != ce)
|
||||
ret = add_cache_entry(nce, options);
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -141,7 +141,7 @@ test_expect_success 'cherry-pick "-" works with arguments' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_failure 'cherry-pick works with dirty renamed file' '
|
||||
test_expect_success 'cherry-pick works with dirty renamed file' '
|
||||
test_commit to-rename &&
|
||||
git checkout -b unrelated &&
|
||||
test_commit unrelated &&
|
||||
|
||||
Reference in New Issue
Block a user