diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2026-01-31 18:59:22 +0100 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-01-31 19:59:40 +0100 |
| commit | 66fdb15abf47df006a7cd29f34f30bec516f37aa (patch) | |
| tree | b7a3e595d79318f917e1fe9e920da2870f2c3e75 | |
| parent | 4c1120b5fd67cdf15b8c790849e068851369852f (diff) | |
thread_sync.c: Fix leak in Queue and SizedQueue
This was introduced in 8ce61f90ba4aea3d52e92e258c3803b8b885726e
| -rw-r--r-- | thread_sync.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/thread_sync.c b/thread_sync.c index e3916c97cb..fa6a60ab62 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -696,13 +696,20 @@ queue_mark_and_move(void *ptr) } } +static inline void +queue_free_buffer(struct rb_queue *q) +{ + if (q->buffer) { + SIZED_FREE_N(q->buffer, q->capa); + } +} + static void queue_free(void *ptr) { struct rb_queue *q = ptr; - if (q->buffer) { - ruby_sized_xfree(q->buffer, q->capa * sizeof(VALUE)); - } + queue_free_buffer(q); + SIZED_FREE(q); } static size_t @@ -806,7 +813,8 @@ static void szqueue_free(void *ptr) { struct rb_szqueue *sq = ptr; - queue_free(&sq->q); + queue_free_buffer(&sq->q); + SIZED_FREE(sq); } static size_t |
