diff_generate: detect memory allocation errors when preparing opts When preparing options for the two iterators that are about to be diffed, we allocate a common prefix for both iterators depending on the options passed by the user. We do not check whether the allocation was successful, though. In fact, this isn't much of a problem, as using a `NULL` prefix is perfectly fine. But in the end, we probably want to detect that the system doesn't have any memory left, as we're unlikely to be able to continue afterwards anyway. While the issue is being fixed in the newly created function `diff_prepare_iterator_opts`, it has been previously existing in the previous macro `DIFF_FROM_ITERATORS` already.
diff --git a/src/diff_generate.c b/src/diff_generate.c
index c054853..b68efb6 100644
--- a/src/diff_generate.c
+++ b/src/diff_generate.c
@@ -1277,6 +1277,7 @@ static int diff_prepare_iterator_opts(char **prefix, git_iterator_options *a, in
b->pathlist.count = opts->pathspec.count;
} else if (opts) {
*prefix = git_pathspec_prefix(&opts->pathspec);
+ GIT_ERROR_CHECK_ALLOC(prefix);
}
a->flags = aflags;