diff options
author | Pauli <pauli@openssl.org> | 2023-11-07 07:32:18 +1100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-11-08 11:09:12 +0000 |
commit | a03108778044cc0d428ce38084ef6f318446fbe3 (patch) | |
tree | f5dc82e21d19476222da02eeef9e5ebd2d9f9d15 /ssl | |
parent | ec0d22fe1571508c08b714715cfdb6ac60c53f78 (diff) | |
download | openssl-a03108778044cc0d428ce38084ef6f318446fbe3.tar.gz |
Fix bug in priority queue remove function
The short circuit in the remove function when the element is the last in the
heap, failed to add the removed slot back to the freelist.
Fixes #22644
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22646)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/priority_queue.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ssl/priority_queue.c b/ssl/priority_queue.c index ab2442aeae..5393c532a7 100644 --- a/ssl/priority_queue.c +++ b/ssl/priority_queue.c @@ -265,8 +265,14 @@ void *ossl_pqueue_remove(OSSL_PQUEUE *pq, size_t elem) ASSERT_USED(pq, n); - if (n == pq->htop - 1) + if (n == pq->htop - 1) { + pq->elements[elem].posn = pq->freelist; + pq->freelist = elem; +#ifndef NDEBUG + pq->elements[elem].used = 0; +#endif return pq->heap[--pq->htop].data; + } if (n > 0) pqueue_force_bottom(pq, n); return ossl_pqueue_pop(pq); |