summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-08-27 10:36:19 +0200
committerPatrick Steinhardt <ps@pks.im>2019-08-27 10:48:26 +0200
commitfe241071317a69dbda10b821fbc909edca2367fb (patch)
tree464ba41152a06583343c5f965633ea6d3c63a30c
parent8a23597b73f4ea83d87ee22bf62c36aadb97e095 (diff)
downloadlibgit2-fe241071317a69dbda10b821fbc909edca2367fb.tar.gz
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.
-rw-r--r--src/diff_generate.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/diff_generate.c b/src/diff_generate.c
index c054853b9..b68efb6ea 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;