Commit da04d3fc by yuangli

fix grafts and shallowarray memory leaks

parent e93d0815
......@@ -43,6 +43,9 @@ int git_grafts_from_file(git_grafts **out, const char *path)
git_grafts *grafts = NULL;
int error;
if (*out)
return git_grafts_refresh(*out);
if ((error = git_grafts_new(&grafts)) < 0)
goto error;
......
......@@ -2150,6 +2150,11 @@ void git_remote_free(git_remote *remote)
remote->transport = NULL;
}
if (remote->nego.shallow_roots) {
git_array_clear(remote->nego.shallow_roots->array);
git__free(remote->nego.shallow_roots);
}
git_vector_free(&remote->refs);
free_refspecs(&remote->refspecs);
......@@ -2164,8 +2169,6 @@ void git_remote_free(git_remote *remote)
free_heads(&remote->local_heads);
git_vector_free(&remote->local_heads);
git_shallowarray_free((remote->nego).shallow_roots);
git_push_free(remote->push);
git__free(remote->url);
git__free(remote->pushurl);
......
......@@ -3346,13 +3346,11 @@ int git_repository__shallow_roots(git_array_oid_t *out, git_repository *repo) {
if (!repo->shallow_grafts && (error = load_grafts(repo)) < 0)
return error;
if ((error = git_grafts_refresh(repo->shallow_grafts)) < 0) {
if ((error = git_grafts_refresh(repo->shallow_grafts)) < 0)
return error;
}
if ((error = git_grafts_get_oids(out, repo->shallow_grafts)) < 0) {
if ((error = git_grafts_get_oids(out, repo->shallow_grafts)) < 0)
return error;
}
return 0;
}
......
......@@ -510,9 +510,3 @@ int git_shallowarray_remove(git_shallowarray *array, git_oid *oid)
/* no git_array_remove… meh */
return -1;
}
void git_shallowarray_free(git_shallowarray *array)
{
git_array_clear(array->array);
git__free(array);
}
......@@ -203,6 +203,4 @@ struct git_shallowarray {
git_array_oid_t array;
};
void git_shallowarray_free(git_shallowarray *array);
#endif
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