Skip to content

Commit 4263051

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 7a0662a commit 4263051

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

871871
ce = index_file_exists(opt->priv->unpack_opts.src_index,
872872
path, strlen(path), ignore_case);
873-
return verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
873+
return !ce || verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
874874
}
875875

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

0 commit comments

Comments
 (0)