From b33e9fbcde3a9c60c1af1ed497bb71304fd8872c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 26 Apr 2021 20:24:39 -0500 Subject: [PATCH] Fix list corruption on entry removal --- src/RtpFecQueue.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/RtpFecQueue.c b/src/RtpFecQueue.c index 05da659..22dcf24 100644 --- a/src/RtpFecQueue.c +++ b/src/RtpFecQueue.c @@ -32,6 +32,9 @@ void RtpfCleanupQueue(PRTP_FEC_QUEUE queue) { } static void insertEntryIntoList(PRTPFEC_QUEUE_LIST list, PRTPFEC_QUEUE_ENTRY entry) { + LC_ASSERT(entry->prev == NULL); + LC_ASSERT(entry->next == NULL); + if (list->head == NULL) { LC_ASSERT(list->count == 0); LC_ASSERT(list->tail == NULL); @@ -51,6 +54,7 @@ static void insertEntryIntoList(PRTPFEC_QUEUE_LIST list, PRTPFEC_QUEUE_ENTRY ent static void removeEntryFromList(PRTPFEC_QUEUE_LIST list, PRTPFEC_QUEUE_ENTRY entry) { LC_ASSERT(entry != NULL); + LC_ASSERT(list->count != 0); LC_ASSERT(list->head != NULL); LC_ASSERT(list->tail != NULL); @@ -62,14 +66,17 @@ static void removeEntryFromList(PRTPFEC_QUEUE_LIST list, PRTPFEC_QUEUE_ENTRY ent } if (entry->prev != NULL) { + LC_ASSERT(entry->prev->next == entry); entry->prev->next = entry->next; - entry->prev = NULL; } if (entry->next != NULL) { + LC_ASSERT(entry->next->prev == entry); entry->next->prev = entry->prev; - entry->next = NULL; } + entry->next = NULL; + entry->prev = NULL; + list->count--; }