Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: third_party/WebKit/Source/wtf/Vector.h

Issue 2657173002: Disallow sequences with lengths exceeding max allocation supported. (Closed)
Patch Set: add expected output Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/Vector.h
diff --git a/third_party/WebKit/Source/wtf/Vector.h b/third_party/WebKit/Source/wtf/Vector.h
index 96a440765a11a1cd6bbcfc8ed511021cbc9b1031..7708f6ca8d45e58ee3b5872441b51f63b5dde331 100644
--- a/third_party/WebKit/Source/wtf/Vector.h
+++ b/third_party/WebKit/Source/wtf/Vector.h
@@ -335,6 +335,8 @@ class VectorBufferBase {
public:
void allocateBuffer(size_t newCapacity) {
DCHECK(newCapacity);
+ DCHECK(newCapacity <=
Yuta Kitamura 2017/01/30 07:19:42 nit+optional: Use DCHECK_LE?
sof 2017/01/31 21:01:43 yes, done.
+ Allocator::template maxElementCountInBackingStore<T>());
size_t sizeToAllocate = allocationSize(newCapacity);
if (hasInlineCapacity)
m_buffer =
@@ -999,6 +1001,12 @@ class Vector
void reverse();
+ // Maximum element count supported; allocating a vector
+ // buffer with a larger count will fail.
+ static size_t maxCapacity() {
+ return Allocator::template maxElementCountInBackingStore<T>();
+ }
+
template <typename VisitorDispatcher>
void trace(VisitorDispatcher);

Powered by Google App Engine
This is Rietveld 408576698