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

Side by Side Diff: src/objects.cc

Issue 525064: Fixed potential length miscalculations by limiting max size of arrays and strings. (Closed)
Patch Set: Added (unrelated) cast to make Win64 compile. Created 10 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 unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 6816 matching lines...) Expand 10 before | Expand all | Expand 10 after
6827 6827
6828 template<typename Shape, typename Key> 6828 template<typename Shape, typename Key>
6829 void HashTable<Shape, Key>::IterateElements(ObjectVisitor* v) { 6829 void HashTable<Shape, Key>::IterateElements(ObjectVisitor* v) {
6830 IteratePointers(v, 6830 IteratePointers(v,
6831 kElementsStartOffset, 6831 kElementsStartOffset,
6832 kHeaderSize + length() * kPointerSize); 6832 kHeaderSize + length() * kPointerSize);
6833 } 6833 }
6834 6834
6835 6835
6836 template<typename Shape, typename Key> 6836 template<typename Shape, typename Key>
6837 Object* HashTable<Shape, Key>::Allocate( 6837 Object* HashTable<Shape, Key>::Allocate(int at_least_space_for) {
6838 int at_least_space_for) {
6839 int capacity = RoundUpToPowerOf2(at_least_space_for); 6838 int capacity = RoundUpToPowerOf2(at_least_space_for);
6840 if (capacity < 4) capacity = 4; // Guarantee min capacity. 6839 if (capacity < 4) {
6840 capacity = 4; // Guarantee min capacity.
6841 } else if (capacity > HashTable::kMaxCapacity) {
6842 return Failure::OutOfMemoryException();
6843 }
6844
6841 Object* obj = Heap::AllocateHashTable(EntryToIndex(capacity)); 6845 Object* obj = Heap::AllocateHashTable(EntryToIndex(capacity));
6842 if (!obj->IsFailure()) { 6846 if (!obj->IsFailure()) {
6843 HashTable::cast(obj)->SetNumberOfElements(0); 6847 HashTable::cast(obj)->SetNumberOfElements(0);
6844 HashTable::cast(obj)->SetNumberOfDeletedElements(0); 6848 HashTable::cast(obj)->SetNumberOfDeletedElements(0);
6845 HashTable::cast(obj)->SetCapacity(capacity); 6849 HashTable::cast(obj)->SetCapacity(capacity);
6846 } 6850 }
6847 return obj; 6851 return obj;
6848 } 6852 }
6849 6853
6850 6854
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
8300 if (break_point_objects()->IsUndefined()) return 0; 8304 if (break_point_objects()->IsUndefined()) return 0;
8301 // Single beak point. 8305 // Single beak point.
8302 if (!break_point_objects()->IsFixedArray()) return 1; 8306 if (!break_point_objects()->IsFixedArray()) return 1;
8303 // Multiple break points. 8307 // Multiple break points.
8304 return FixedArray::cast(break_point_objects())->length(); 8308 return FixedArray::cast(break_point_objects())->length();
8305 } 8309 }
8306 #endif 8310 #endif
8307 8311
8308 8312
8309 } } // namespace v8::internal 8313 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698