From 29a62558c4faf4de2cdc52d34fc497dfd97e0402 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 21 Jul 2019 12:51:54 +0200 Subject: [PATCH] AK: Fix off-by-one in Vector::prepend(Vector&&). Caught by valgrind's uninitialized access checks on the Vector unit test. Yay for finding bugs with valgrind on the unit tests! :^) --- AK/Vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/Vector.h b/AK/Vector.h index f8e85cb197..1e2dc53bb3 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -362,7 +362,7 @@ public: auto other_size = other.size(); grow_capacity(size() + other_size); - for (int i = size() + other_size - 1; i > other.size(); --i) { + for (int i = size() + other_size - 1; i >= other.size(); --i) { new (slot(i)) T(move(at(i - other_size))); at(i - other_size).~T(); }