Skip to content

Commit 02f7059

Browse files
dschomjcheetham
authored andcommitted
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 7b525d9 commit 02f7059

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
@@ -880,7 +880,7 @@ static int was_dirty(struct merge_options *opt, const char *path)
880880

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

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

0 commit comments

Comments
 (0)