From: Alan T. DeKok Date: Mon, 16 Aug 2021 20:21:30 +0000 (-0400) Subject: Revert "don't pass NULL to insert after/before" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0601adeca119045bc8b6dcc350da5ae5264f3d58;p=thirdparty%2Ffreeradius-server.git Revert "don't pass NULL to insert after/before" This reverts commit 320e4d4fd63497a0524ecaa3584eca89d06b6e5f. --- diff --git a/src/lib/util/dlist.h b/src/lib/util/dlist.h index b967f20a23f..14fd671a229 100644 --- a/src/lib/util/dlist.h +++ b/src/lib/util/dlist.h @@ -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;