]> git.proxmox.com Git - libgit2.git/commitdiff
Fix segfault when iterating a revlist backwards
authorVicent Marti <tanoku@gmail.com>
Fri, 18 Feb 2011 10:23:53 +0000 (12:23 +0200)
committerVicent Marti <tanoku@gmail.com>
Fri, 18 Feb 2011 10:23:53 +0000 (12:23 +0200)
The `prev` and `next` pointers were not being updated after popping one
of the list elements.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
src/revwalk.c

index 2237e333d009f799fa6bb29dfd9ba07bf3a6d808..e30e543a8345eb7e3ef54ee444ad822a78676ca5 100644 (file)
@@ -329,6 +329,8 @@ git_revwalk_commit *git_revwalk_list_pop_back(git_revwalk_list *list)
        list->tail = list->tail->prev;
        if (list->tail == NULL)
                list->head = NULL;
+       else
+               list->tail->next = NULL;
 
        commit = node->walk_commit;
        free(node);
@@ -350,6 +352,8 @@ git_revwalk_commit *git_revwalk_list_pop_front(git_revwalk_list *list)
        list->head = list->head->next;
        if (list->head == NULL)
                list->tail = NULL;
+       else
+               list->head->prev = NULL;
 
        commit = node->walk_commit;
        free(node);