]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib, bgpd: fix crash using skiplist debug function
authorEmanuele Bovisio <emanuele.bovisio@eolo.it>
Thu, 5 Nov 2020 13:36:00 +0000 (14:36 +0100)
committerEmanuele Bovisio <emanuele.bovisio@eolo.it>
Tue, 10 Nov 2020 18:01:56 +0000 (19:01 +0100)
calling "skiplist test" and then "skiplist debug",
there was a crash due to a freed pointer.

Agreed to remove static pointer (see PR #7474).

Signed-off-by: Emanuele Bovisio <emanuele.bovisio@eolo.it>
lib/skiplist.c

index 2bef18f525486a35c2974019d1940f9642fb56c5..b79dfa67722f1c4b8ce27d8df97f02c1fa372224 100644 (file)
@@ -74,7 +74,6 @@ DEFINE_MTYPE_STATIC(LIB, SKIP_LIST_NODE, "Skip Node")
 
 static int randomsLeft;
 static int randomBits;
-static struct skiplist *skiplist_last_created; /* debugging hack */
 
 #if 1
 #define CHECKLAST(sl)                                                          \
@@ -150,8 +149,6 @@ struct skiplist *skiplist_new(int flags,
        if (del)
                new->del = del;
 
-       skiplist_last_created = new; /* debug */
-
        return new;
 }
 
@@ -586,7 +583,8 @@ void skiplist_debug(struct vty *vty, struct skiplist *l)
        int i;
 
        if (!l)
-               l = skiplist_last_created;
+               return;
+
        vty_out(vty, "Skiplist %p has max level %d\n", l, l->level);
        for (i = l->level; i >= 0; --i)
                vty_out(vty, "  @%d: %ld\n", i,