ArrayQueue's push_front is not panic-safe
Moderate severity
GitHub Reviewed
Published
Sep 2, 2025
to the GitHub Advisory Database
•
Updated Sep 2, 2025
Description
Published to the GitHub Advisory Database
Sep 2, 2025
Reviewed
Sep 2, 2025
Last updated
Sep 2, 2025
The safe API
array_queue::ArrayQueue::push_front
can lead to deallocating uninitialized memory if a panic occurs while invoking theclone
method on the passed argument.Specifically,
push_front
receives an argument that is intended to be cloned and pushed, whose type implements theClone
trait. Furthermore, the method updates the queue'sstart
index before initializing the slot for the newly pushed element. User-defined implementations ofClone
may include aclone
method that can panic. If such a panic occurs during initialization, the structure is left with an advancedstart
index pointing to an uninitialized slot. WhenArrayQueue
is later dropped, its destructor treats that slot as initialized and attempts to drop it, resulting in an attempt to free uninitialized memory.The bug was fixed in commit
728fe1b
.References