ports/net/quagga/files/patch-pqueue.c
Eugene Grosbein f29fab6043
net/quagga: add three bugfixes from upstream
This change imports three post-1.2.4 release changes
from the primary Git repository of Quagga Project:

1) Fix threading error that broke ripd:
1f918980c0

2) Fix memory corruption that may occur
when limit.rlim_cur is less then FD_SETSIZE:
b54de751ef

3) Prevent queue corruption when removing the last entry of queues
e21719d8fa

PR:		261205
Approved by:	pi (maintainer)
2022-01-15 16:48:03 +07:00

14 lines
484 B
C

--- 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],