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

Unified Diff: third_party/WebKit/Source/platform/wtf/allocator/Partitions.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
« no previous file with comments | « third_party/WebKit/Source/platform/wtf/TerminatedArray.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/wtf/allocator/Partitions.h
diff --git a/third_party/WebKit/Source/platform/wtf/allocator/Partitions.h b/third_party/WebKit/Source/platform/wtf/allocator/Partitions.h
index 67e87bb4615d158905444d7b7b6fb8bbdea56237..2b17085ca6920c5b13560c13b23add48b3f9597a 100644
--- a/third_party/WebKit/Source/platform/wtf/allocator/Partitions.h
+++ b/third_party/WebKit/Source/platform/wtf/allocator/Partitions.h
@@ -34,6 +34,7 @@
#include <string.h>
#include "base/allocator/partition_allocator/partition_alloc.h"
#include "base/allocator/partition_allocator/spin_lock.h"
+#include "base/numerics/checked_math.h"
#include "platform/wtf/Assertions.h"
#include "platform/wtf/WTF.h"
#include "platform/wtf/WTFExport.h"
@@ -68,11 +69,18 @@ class WTF_EXPORT Partitions {
NOTREACHED();
return nullptr;
}
+
ALWAYS_INLINE static base::PartitionRoot* LayoutPartition() {
DCHECK(initialized_);
return layout_allocator_.root();
}
+ ALWAYS_INLINE static size_t ComputeAllocationSize(size_t count, size_t size) {
+ base::CheckedNumeric<size_t> total = count;
+ total *= size;
+ return total.ValueOrDie();
+ }
+
static size_t CurrentDOMMemoryUsage() {
NOTREACHED();
return 0;
« no previous file with comments | « third_party/WebKit/Source/platform/wtf/TerminatedArray.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698