Skip to content

Commit

Permalink
Avoid a segmentation fault with renaming merges
Browse files Browse the repository at this point in the history
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 <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Dec 6, 2016
1 parent d69a4b1 commit 1ed2ac6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +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)
return err(o, _("addinfo_cache failed for path '%s'"), path);
if (nce != ce)
if (nce && nce != ce)
ret = add_cache_entry(nce, options);
}
return ret;
Expand Down

0 comments on commit 1ed2ac6

Please sign in to comment.