summaryrefslogtreecommitdiff
path: root/net/quagga/files/patch-pqueue.c
blob: c00e7f6efcaa87d163b9d71772abea559a88477f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
--- lib/pqueue.c.orig	2018-02-20 04:24:55.000000000 +0700
+++ lib/pqueue.c	2022-01-15 00:17:05.525677000 +0700
@@ -172,7 +172,10 @@ pqueue_dequeue (struct pqueue *queue)
 void
 pqueue_remove_at (int index, struct pqueue *queue)
 {
-  queue->array[index] = queue->array[--queue->size];
+  if (index == --queue->size)
+    return; /* we're removing the last entry */
+
+  queue->array[index] = queue->array[queue->size];
 
   if (index > 0
       && (*queue->cmp) (queue->array[index],