Skip to content

Commit 2dfd89c

Browse files
committed
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 #952 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 6adf713 commit 2dfd89c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int add_cacheinfo(struct merge_options *o,
235235
struct cache_entry *nce;
236236

237237
nce = refresh_cache_entry(ce, CE_MATCH_REFRESH | CE_MATCH_IGNORE_MISSING);
238-
if (nce != ce)
238+
if (nce && nce != ce)
239239
ret = add_cache_entry(nce, options);
240240
}
241241
return ret;

t/t3501-revert-cherry-pick.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ test_expect_success 'cherry-pick "-" works with arguments' '
141141
test_cmp expect actual
142142
'
143143

144-
test_expect_failure 'cherry-pick works with dirty renamed file' '
144+
test_expect_success 'cherry-pick works with dirty renamed file' '
145145
test_commit to-rename &&
146146
git checkout -b unrelated &&
147147
test_commit unrelated &&

0 commit comments

Comments
 (0)