Commit 9dcd8cee by Vicent Marti

Merge pull request #2039 from brodie/brodie/handle-null-on-free

Fix places in public free() functions where NULL pointers aren't handled
parents 426d8456 2fcc0d07
......@@ -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]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment