From: Timo Sirainen Date: Mon, 4 Oct 2010 16:16:38 +0000 (+0100) Subject: priority queue: Set item's idx value to invalid when it's removed from queue. X-Git-Tag: 2.0.6~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e622ff624ff28a35be8852451d21cb9491c845d4;p=thirdparty%2Fdovecot%2Fcore.git priority queue: Set item's idx value to invalid when it's removed from queue. This should assert-crash on double-removes more reliably. --- diff --git a/src/lib/priorityq.c b/src/lib/priorityq.c index 7cd297700d..37263ffd25 100644 --- a/src/lib/priorityq.c +++ b/src/lib/priorityq.c @@ -136,6 +136,7 @@ static void priorityq_remove_idx(struct priorityq *pq, unsigned int idx) void priorityq_remove(struct priorityq *pq, struct priorityq_item *item) { priorityq_remove_idx(pq, item->idx); + item->idx = -1U; } struct priorityq_item *priorityq_peek(struct priorityq *pq) @@ -154,8 +155,10 @@ struct priorityq_item *priorityq_pop(struct priorityq *pq) struct priorityq_item *item; item = priorityq_peek(pq); - if (item != NULL) + if (item != NULL) { priorityq_remove_idx(pq, 0); + item->idx = -1U; + } return item; }