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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapTerminatedArray.h

Issue 2957583004: Check for integer overflow in allocations. (Closed)
Patch Set: Rename the function to |ComputeAllocationSize|. Created 3 years, 6 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/platform/heap/HeapTerminatedArray.h
diff --git a/third_party/WebKit/Source/platform/heap/HeapTerminatedArray.h b/third_party/WebKit/Source/platform/heap/HeapTerminatedArray.h
index 37545ef625dfc264d2f5eb81cf40b4244162c3ad..6be8824e973447699910e282a563ba8ff243a8f0 100644
--- a/third_party/WebKit/Source/platform/heap/HeapTerminatedArray.h
+++ b/third_party/WebKit/Source/platform/heap/HeapTerminatedArray.h
@@ -8,6 +8,7 @@
#include "platform/heap/Heap.h"
#include "platform/wtf/TerminatedArray.h"
#include "platform/wtf/TerminatedArrayBuilder.h"
+#include "platform/wtf/allocator/Partitions.h"
namespace blink {
@@ -38,13 +39,15 @@ class HeapTerminatedArray : public TerminatedArray<T> {
static PassPtr Create(size_t capacity) {
return reinterpret_cast<HeapTerminatedArray*>(
ThreadHeap::Allocate<HeapTerminatedArray>(
- capacity * sizeof(T), IsEagerlyFinalizedType<T>::value));
+ WTF::Partitions::ComputeAllocationSize(capacity, sizeof(T)),
+ IsEagerlyFinalizedType<T>::value));
}
static PassPtr Resize(PassPtr ptr, size_t capacity) {
return reinterpret_cast<HeapTerminatedArray*>(
- ThreadHeap::Reallocate<HeapTerminatedArray>(ptr,
- capacity * sizeof(T)));
+ ThreadHeap::Reallocate<HeapTerminatedArray>(
+ ptr,
+ WTF::Partitions::ComputeAllocationSize(capacity, sizeof(T))));
}
};
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSSelectorList.cpp ('k') | third_party/WebKit/Source/platform/wtf/TerminatedArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698