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_frontcan lead to deallocating uninitialized memory if a panic occurs while invoking theclonemethod on the passed argument.Specifically,
push_frontreceives an argument that is intended to be cloned and pushed, whose type implements theClonetrait. Furthermore, the method updates the queue'sstartindex before initializing the slot for the newly pushed element. User-defined implementations ofClonemay include aclonemethod that can panic. If such a panic occurs during initialization, the structure is left with an advancedstartindex pointing to an uninitialized slot. WhenArrayQueueis 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