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.
This commit is contained in:
Johannes Schindelin 2019-05-21 23:17:46 +02:00 коммит произвёл Victoria Dye
Родитель 92aa3dedc2
Коммит 24877a61d8
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -877,7 +877,7 @@ static int was_dirty(struct merge_options *opt, const char *path)
ce = index_file_exists(opt->priv->unpack_opts.src_index,
path, strlen(path), ignore_case);
return verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
return !ce || verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
}
static int make_room_for_path(struct merge_options *opt, const char *path)