From 1a3e03857e9d839edd610db15eb7981a0fb221c2 Mon Sep 17 00:00:00 2001 From: Scott Vokes Date: Wed, 15 May 2024 15:09:23 -0400 Subject: [PATCH] queue: Fix a read past the end of the queue. --- src/adt/queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adt/queue.c b/src/adt/queue.c index 95f059ce7..1e5d28e08 100644 --- a/src/adt/queue.c +++ b/src/adt/queue.c @@ -51,7 +51,7 @@ queue_push(struct queue *q, fsm_state_t state) * memmove everything after reading 1. */ if (q->rd > 0 && q->rd < q->wr) { memmove(&q->q[0], &q->q[q->rd], - q->rd * sizeof(q->q[0])); + (q->capacity - q->rd) * sizeof(q->q[0])); q->wr -= q->rd; q->rd = 0; } else {