Fix bug in GListTruncate, extends templates tests
[tedtools.git] / glist.c
diff --git a/glist.c b/glist.c
index 59213ac..9e79963 100644 (file)
--- a/glist.c
+++ b/glist.c
@@ -118,11 +118,15 @@ GListDelete(GList *l, GListCell *c) {
                l->head = c->next;
                if ( l->head ) 
                        l->head->prev = NULL;
+               else
+                       l->tail = NULL;
        } else if ( l->tail == c ) {
                tassert( c->next == NULL );
                l->tail = c->prev;
                if ( l->tail )
                        l->tail->next = NULL;
+               else
+                       l->head = NULL;
        } else {
                c->prev->next = c->next;
                c->next->prev = c->prev;
@@ -281,6 +285,7 @@ GListTruncate(GList *l, int n) {
                GListFreeCell(l, c);
        }
 
+       checkGList(l);
        return l;
 }