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

Unified Diff: runtime/vm/object.h

Issue 949343002: Fix array-out-of-bounds in TypedDataView::ElementSizeInBytes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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 | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 43765)
+++ runtime/vm/object.h (working copy)
@@ -6949,7 +6949,7 @@
static intptr_t ElementSizeInBytes(intptr_t class_id) {
ASSERT(RawObject::IsTypedDataClassId(class_id));
- return element_size[ElementType(class_id)];
+ return element_size(ElementType(class_id));
}
static TypedDataElementType ElementType(intptr_t class_id) {
@@ -7030,7 +7030,14 @@
}
private:
- static const intptr_t element_size[];
+ static intptr_t element_size(intptr_t index) {
+ ASSERT(0 <= index && index < kNumElementSizes);
+ intptr_t size = element_size_table[index]
+ ASSERT(size != 0);
+ return size;
+ }
+ static const intptr_t kNumElementSizes = 14;
Ivan Posva 2015/02/25 23:52:44 Where does 14 come from?
koda 2015/02/25 23:57:59 That's the number of elements in the array; see ob
Ivan Posva 2015/02/26 00:15:44 Isn't it "(kTypedDataFloat64x2ArrayCid - kTypedDat
koda 2015/02/27 18:21:57 Done. Sure. Until we add another type :) In any c
+ static const intptr_t element_size_table[kNumElementSizes];
FINAL_HEAP_OBJECT_IMPLEMENTATION(TypedData, Instance);
friend class Class;
@@ -7107,7 +7114,7 @@
static intptr_t ElementSizeInBytes(intptr_t class_id) {
ASSERT(RawObject::IsExternalTypedDataClassId(class_id));
- return TypedData::element_size[ElementType(class_id)];
+ return TypedData::element_size(ElementType(class_id));
}
static TypedDataElementType ElementType(intptr_t class_id) {
@@ -7200,8 +7207,7 @@
static intptr_t ElementSizeInBytes(intptr_t class_id) {
ASSERT(RawObject::IsTypedDataViewClassId(class_id));
return (class_id == kByteDataViewCid) ?
- TypedData::element_size[kTypedDataInt8ArrayCid] :
- TypedData::element_size[class_id - kTypedDataInt8ArrayViewCid];
+ 1 : TypedData::element_size(class_id - kTypedDataInt8ArrayViewCid);
}
private:
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698