commit a162a2194744ed9d9c095f0160e463a7a1b4e36c (tree)
parent ecee1cae454ad5924f4698caaa712348858d9179
Author: Zander Khan <git@zander.xyz>
Date: Sat, 16 Jan 2021 17:52:14 +0000
Ensure we cannot remove an item outside the current length of the queue
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/lib/std/priority_dequeue.zig b/lib/std/priority_dequeue.zig
@@ -191,6 +191,7 @@ pub fn PriorityDequeue(comptime T: type) type {
/// same order as iterator, which is not necessarily priority
/// order.
pub fn removeIndex(self: *Self, index: usize) T {
+ assert(self.len > index);
const item = self.items[index];
const last = self.items[self.len - 1];