]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Revert "don't pass NULL to insert after/before"
authorAlan T. DeKok <aland@freeradius.org>
Mon, 16 Aug 2021 20:21:30 +0000 (16:21 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 16 Aug 2021 20:21:30 +0000 (16:21 -0400)
This reverts commit 320e4d4fd63497a0524ecaa3584eca89d06b6e5f.

src/lib/util/dlist.h

index b967f20a23fe7a7a3e4b7b15176ea1b608fcb7d7..14fd671a22995673390ead6cb1e65dfbe0710c71 100644 (file)
@@ -353,7 +353,11 @@ static inline CC_HINT(nonnull) int fr_dlist_insert_after(fr_dlist_head_t *list_h
 #endif
 
        entry = fr_dlist_item_to_entry(list_head->offset, ptr);
-       pos_entry = fr_dlist_item_to_entry(list_head->offset, pos);
+       if (!pos) {
+               pos_entry = &(list_head->entry);
+       } else {
+               pos_entry = fr_dlist_item_to_entry(list_head->offset, pos);
+       }
 
        if (!fr_cond_assert(pos_entry->next != NULL)) return -1;
        if (!fr_cond_assert(pos_entry->prev != NULL)) return -1;
@@ -385,7 +389,11 @@ static inline CC_HINT(nonnull) int fr_dlist_insert_before(fr_dlist_head_t *list_
 #endif
 
        entry = fr_dlist_item_to_entry(list_head->offset, ptr);
-       pos_entry = fr_dlist_item_to_entry(list_head->offset, pos);
+       if (!pos) {
+               pos_entry = &(list_head->entry);
+       } else {
+               pos_entry = fr_dlist_item_to_entry(list_head->offset, pos);
+       }
 
        if (!fr_cond_assert(pos_entry->next != NULL)) return -1;
        if (!fr_cond_assert(pos_entry->prev != NULL)) return -1;