summaryrefslogtreecommitdiffstats
path: root/mfbt/Vector.h
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2017-06-21 17:02:50 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-02-05 19:17:30 +0100
commit9ba0c19352ef61c998aef18a1de9a98c66a7291f (patch)
tree4a3ed801cc9aed806cfe62fdb85f4801327a7d3e /mfbt/Vector.h
parent6b5575eb99714967b38aa2b2b71e5e72d2f97b81 (diff)
downloadUXP-9ba0c19352ef61c998aef18a1de9a98c66a7291f.tar
UXP-9ba0c19352ef61c998aef18a1de9a98c66a7291f.tar.gz
UXP-9ba0c19352ef61c998aef18a1de9a98c66a7291f.tar.lz
UXP-9ba0c19352ef61c998aef18a1de9a98c66a7291f.tar.xz
UXP-9ba0c19352ef61c998aef18a1de9a98c66a7291f.zip
Fix off-by-one in Vector::insert.
Diffstat (limited to 'mfbt/Vector.h')
-rw-r--r--mfbt/Vector.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/mfbt/Vector.h b/mfbt/Vector.h
index fc43afcf1..07e370426 100644
--- a/mfbt/Vector.h
+++ b/mfbt/Vector.h
@@ -1232,10 +1232,10 @@ Vector<T, N, AP>::insert(T* aP, U&& aVal)
}
} else {
T oldBack = Move(back());
- if (!append(Move(oldBack))) { /* Dup the last element. */
+ if (!append(Move(oldBack))) {
return nullptr;
}
- for (size_t i = oldLength; i > pos; --i) {
+ for (size_t i = oldLength - 1; i > pos; --i) {
(*this)[i] = Move((*this)[i - 1]);
}
(*this)[pos] = Forward<U>(aVal);