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

Unified Diff: third_party/WebKit/Source/core/css/CSSSelectorList.cpp

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 | « no previous file | third_party/WebKit/Source/platform/heap/HeapTerminatedArray.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/CSSSelectorList.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSSelectorList.cpp b/third_party/WebKit/Source/core/css/CSSSelectorList.cpp
index cd0c10f4d0170c17533d5c977e9ffcc0e4a3bbf4..6be106a6dd7779170b64a07f57e327cdb9324f4d 100644
--- a/third_party/WebKit/Source/core/css/CSSSelectorList.cpp
+++ b/third_party/WebKit/Source/core/css/CSSSelectorList.cpp
@@ -47,7 +47,8 @@ CSSSelectorList CSSSelectorList::Copy() const {
unsigned length = this->ComputeLength();
list.selector_array_ =
reinterpret_cast<CSSSelector*>(WTF::Partitions::FastMalloc(
- sizeof(CSSSelector) * length, kCSSSelectorTypeName));
+ WTF::Partitions::ComputeAllocationSize(length, sizeof(CSSSelector)),
+ kCSSSelectorTypeName));
for (unsigned i = 0; i < length; ++i)
new (&list.selector_array_[i]) CSSSelector(selector_array_[i]);
@@ -65,9 +66,10 @@ CSSSelectorList CSSSelectorList::AdoptSelectorVector(
DCHECK(flattened_size);
CSSSelectorList list;
- list.selector_array_ =
- reinterpret_cast<CSSSelector*>(WTF::Partitions::FastMalloc(
- sizeof(CSSSelector) * flattened_size, kCSSSelectorTypeName));
+ list.selector_array_ = reinterpret_cast<CSSSelector*>(
+ WTF::Partitions::FastMalloc(WTF::Partitions::ComputeAllocationSize(
+ flattened_size, sizeof(CSSSelector)),
+ kCSSSelectorTypeName));
size_t array_index = 0;
for (size_t i = 0; i < selector_vector.size(); ++i) {
CSSParserSelector* current = selector_vector[i].get();
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapTerminatedArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698