]> git.pond.sub.org Git - empserver/commitdiff
Zap next uid in clink_rem(), check it in clink_add()
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 12 Sep 2008 02:10:14 +0000 (22:10 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 12 Sep 2008 22:34:11 +0000 (18:34 -0400)
The former ensures that next links are valid even for uids not on any
list.  The latter oopses on adding an uid to a list when it is already
on a list, unless it is at the tail.

src/lib/common/cargo.c

index cf8a6282c09e3224d6ca00fd7c74e6178a6e23c3..0dc371278365835aa9aa50bc0392efab21b7fa38 100644 (file)
@@ -144,6 +144,7 @@ clink_add(struct clink *cl, int type, int uid)
        return;
     if (CANT_HAPPEN(*head >= nclink[type]))
        *head = -1;
+    CANT_HAPPEN(clink[type][uid].next >= 0);
     clink[type][uid].next = *head;
     *head = uid;
 }
@@ -171,6 +172,7 @@ clink_rem(struct clink *cl, int type, int uid)
     }
 
     *p = linkv[uid].next;
+    linkv[uid].next = -1;
 }
 
 /*