Skip to content

Commit fe24107

Browse files
committed
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.
1 parent 8a23597 commit fe24107

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/diff_generate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,7 @@ static int diff_prepare_iterator_opts(char **prefix, git_iterator_options *a, in
12771277
b->pathlist.count = opts->pathspec.count;
12781278
} else if (opts) {
12791279
*prefix = git_pathspec_prefix(&opts->pathspec);
1280+
GIT_ERROR_CHECK_ALLOC(prefix);
12801281
}
12811282

12821283
a->flags = aflags;

0 commit comments

Comments
 (0)