Skip to content

Commit 47d58ff

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 c5e4ee0 commit 47d58ff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

merge-recursive.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ static int was_dirty(struct merge_options *opt, const char *path)
875875

876876
ce = index_file_exists(opt->priv->unpack_opts.src_index,
877877
path, strlen(path), ignore_case);
878-
return verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
878+
return !ce || verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
879879
}
880880

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

0 commit comments

Comments
 (0)