-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Box<[T]> instead of Vec<T> to initialize and drop ArrayQueue
Previously, the queue buffer was initialized using Vec::with_capacity. Note the with_capacity does not guarantee that precise capacity; the actual layout of the allocated memory could have a greater size. The drop code assumed the buffer has a size equal to the queue's capacity. This is undefined behavior when the buffer actually has a greater size. Using Box<[T]> instead guarantees an exact capacity, resolving the UB.
- Loading branch information
1 parent
81ab18e
commit be327d5
Showing
3 changed files
with
17 additions
and
9 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters