From 4f1ba728765957a8ae262f4a32c843b3538f90c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=9F=E6=B0=91?= Date: Thu, 2 Dec 2021 09:16:35 +0800 Subject: [PATCH] fix: fix the bug that calling the DListRemove may be NULL pointer when not call the function of DListHeadInit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张伟民 --- include/utils/hdf_dlist.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/utils/hdf_dlist.h b/include/utils/hdf_dlist.h index 196a4d2c8..4d4ad67c3 100644 --- a/include/utils/hdf_dlist.h +++ b/include/utils/hdf_dlist.h @@ -80,8 +80,13 @@ static inline bool DListIsEmpty(const struct DListHead *head) */ static inline void DListRemove(struct DListHead *entry) { - entry->prev->next = entry->next; - entry->next->prev = entry->prev; + if (entry->prev != NULL) { + entry->prev->next = entry->next; + } + + if (entry->next != NULL) { + entry->next->prev = entry->prev; + } entry->prev = NULL; entry->next = NULL; -- Gitee