mirror of
https://git.proxmox.com/git/libgit2
synced 2026-08-18 20:21:39 +00:00
Merge pull request #2039 from brodie/brodie/handle-null-on-free
Fix places in public free() functions where NULL pointers aren't handled
This commit is contained in:
commit
9dcd8cee6e
@ -181,6 +181,9 @@ void git_branch_iterator_free(git_branch_iterator *_iter)
|
||||
{
|
||||
branch_iter *iter = (branch_iter *) _iter;
|
||||
|
||||
if (iter == NULL)
|
||||
return;
|
||||
|
||||
git_reference_iterator_free(iter->iter);
|
||||
git__free(iter);
|
||||
}
|
||||
|
||||
@ -927,6 +927,9 @@ int git_config_next(git_config_entry **entry, git_config_iterator *iter)
|
||||
|
||||
void git_config_iterator_free(git_config_iterator *iter)
|
||||
{
|
||||
if (iter == NULL)
|
||||
return;
|
||||
|
||||
iter->free(iter);
|
||||
}
|
||||
|
||||
|
||||
@ -949,6 +949,9 @@ int git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len)
|
||||
|
||||
void git_odb_stream_free(git_odb_stream *stream)
|
||||
{
|
||||
if (stream == NULL)
|
||||
return;
|
||||
|
||||
git__free(stream->hash_ctx);
|
||||
stream->free(stream);
|
||||
}
|
||||
|
||||
@ -314,6 +314,9 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length)
|
||||
|
||||
void git_oid_shorten_free(git_oid_shorten *os)
|
||||
{
|
||||
if (os == NULL)
|
||||
return;
|
||||
|
||||
git__free(os->nodes);
|
||||
git__free(os);
|
||||
}
|
||||
|
||||
@ -724,6 +724,9 @@ int git_reference_next_name(const char **out, git_reference_iterator *iter)
|
||||
|
||||
void git_reference_iterator_free(git_reference_iterator *iter)
|
||||
{
|
||||
if (iter == NULL)
|
||||
return;
|
||||
|
||||
git_refdb_iterator_free(iter);
|
||||
}
|
||||
|
||||
|
||||
@ -140,6 +140,10 @@ int git_libgit2_opts(int key, ...)
|
||||
void git_strarray_free(git_strarray *array)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (array == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < array->count; ++i)
|
||||
git__free(array->strings[i]);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user