Skip to content

Commit d1af813

Browse files
committed
merge-recursive: add some defensive coding to was_dirty()
It took this developer quite a good while to understand why the current code cannot get a `NULL` returned by `index_file_exists()`. To un-confuse readers (and future-proof the code), let's just be safe and check before we dereference the returned pointer.
1 parent 4d09641 commit d1af813

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ static int was_dirty(struct merge_options *opt, const char *path)
881881

882882
ce = index_file_exists(opt->priv->unpack_opts.src_index,
883883
path, strlen(path), ignore_case);
884-
return verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
884+
return !ce || verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
885885
}
886886

887887
static int make_room_for_path(struct merge_options *opt, const char *path)

0 commit comments

Comments
 (0)