Skip to content

diff: fix OOM on AIX when finding similar deltas in empty diff#4761

Merged
ethomson merged 1 commit into
libgit2:masterfrom
pks-t:pks/aix-diff-oom
Aug 9, 2018
Merged

diff: fix OOM on AIX when finding similar deltas in empty diff#4761
ethomson merged 1 commit into
libgit2:masterfrom
pks-t:pks/aix-diff-oom

Conversation

@pks-t
Copy link
Copy Markdown
Member

@pks-t pks-t commented Aug 9, 2018

The function git_diff_find_similar keeps a function of cache
similarity metrics signatures, whose size depends on the number of
deltas passed in via the diff parameter. In case where the diff is
empty and thus doesn't have any deltas at all, we may end up allocating
this cache via a call to git__calloc(0, sizeof(void *)). At least on
AIX, allocating 0 bytes will result in a NULL pointer being returned,
which causes us to erroneously return an OOM error.

Fix this situation by simply returning early in case where we are being
passed an empty diff, as we cannot find any similarities in that case
anyway.


This should fix #4748

The function `git_diff_find_similar` keeps a function of cache
similarity metrics signatures, whose size depends on the number of
deltas passed in via the `diff` parameter. In case where the diff is
empty and thus doesn't have any deltas at all, we may end up allocating
this cache via a call to `git__calloc(0, sizeof(void *))`. At least on
AIX, allocating 0 bytes will result in a `NULL` pointer being returned,
which causes us to erroneously return an OOM error.

Fix this situation by simply returning early in case where we are being
passed an empty diff, as we cannot find any similarities in that case
anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Out of memory error on AIX

2 participants