diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-08-27 10:36:19 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2020-03-26 16:20:17 +0100 |
commit | ad735bf3cc2e0af6671c5e5a8c3dd77a974b50e6 (patch) | |
tree | 9790b97c05275c878adfd238d57e9d9c0d158ec6 | |
parent | 7aa03e92cbba38de4eff52bfada3dbec18610451 (diff) | |
download | libgit2-ad735bf3cc2e0af6671c5e5a8c3dd77a974b50e6.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.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/diff_generate.c b/src/diff_generate.c index 3c63efa32..c73ba0dcb 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; |