summaryrefslogtreecommitdiff
path: root/src/revwalk.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-12-13 03:43:56 +0200
committerVicent Marti <tanoku@gmail.com>2010-12-13 03:43:56 +0200
commit1f080e2da4833004fd178f622271879336085e22 (patch)
tree090d226c3d0da7473bc6d7ae687a1c58226b5d45 /src/revwalk.c
parente0d9e12e502582d33f3e54bd77b274aaadbd60c6 (diff)
downloadlibgit2-1f080e2da4833004fd178f622271879336085e22.tar.gz
Fix initialization & freeing of inexistent repos
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/revwalk.c')
-rw-r--r--src/revwalk.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index b724f77c8..f2eaa710f 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -77,6 +77,9 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
void git_revwalk_free(git_revwalk *walk)
{
+ if (walk == NULL)
+ return;
+
git_revwalk_reset(walk);
git_hashtable_free(walk->commits);
free(walk);
@@ -90,6 +93,8 @@ git_repository *git_revwalk_repository(git_revwalk *walk)
int git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
{
+ assert(walk);
+
if (walk->walking)
return GIT_EBUSY;
@@ -165,6 +170,7 @@ static git_revwalk_commit *insert_commit(git_revwalk *walk, git_commit *commit_o
int git_revwalk_push(git_revwalk *walk, git_commit *commit)
{
+ assert(walk && commit);
return insert_commit(walk, commit) ? GIT_SUCCESS : GIT_ENOMEM;
}
@@ -186,6 +192,8 @@ static void mark_uninteresting(git_revwalk_commit *commit)
int git_revwalk_hide(git_revwalk *walk, git_commit *commit)
{
git_revwalk_commit *hide;
+
+ assert(walk && commit);
hide = insert_commit(walk, commit);
if (hide == NULL)
@@ -216,6 +224,8 @@ git_commit *git_revwalk_next(git_revwalk *walk)
{
git_revwalk_commit *next;
+ assert(walk);
+
if (!walk->walking)
prepare_walk(walk);
@@ -234,6 +244,8 @@ void git_revwalk_reset(git_revwalk *walk)
git_hashtable_iterator it;
git_revwalk_commit *commit;
+ assert(walk);
+
git_hashtable_iterator_init(walk->commits, &it);
while ((commit = (git_revwalk_commit *)