Commit 9aa75ed9 authored by danno@chromium.org's avatar danno@chromium.org

Fix out-of-bounds access in fetching propery names

R=vegorov@chromium.org
BUG=chromium:91517
TEST=none

Review URL: http://codereview.chromium.org/7565009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8823 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 767debf7
...@@ -9537,7 +9537,9 @@ void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) { ...@@ -9537,7 +9537,9 @@ void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) {
} }
ASSERT(storage->length() >= index); ASSERT(storage->length() >= index);
} else { } else {
property_dictionary()->CopyKeysTo(storage, StringDictionary::UNSORTED); property_dictionary()->CopyKeysTo(storage,
index,
StringDictionary::UNSORTED);
} }
} }
...@@ -10286,6 +10288,7 @@ template MaybeObject* Dictionary<NumberDictionaryShape, uint32_t>::Shrink( ...@@ -10286,6 +10288,7 @@ template MaybeObject* Dictionary<NumberDictionaryShape, uint32_t>::Shrink(
template void Dictionary<StringDictionaryShape, String*>::CopyKeysTo( template void Dictionary<StringDictionaryShape, String*>::CopyKeysTo(
FixedArray*, FixedArray*,
int,
Dictionary<StringDictionaryShape, String*>::SortMode); Dictionary<StringDictionaryShape, String*>::SortMode);
template int template int
...@@ -11415,11 +11418,11 @@ void StringDictionary::CopyEnumKeysTo(FixedArray* storage, ...@@ -11415,11 +11418,11 @@ void StringDictionary::CopyEnumKeysTo(FixedArray* storage,
template<typename Shape, typename Key> template<typename Shape, typename Key>
void Dictionary<Shape, Key>::CopyKeysTo( void Dictionary<Shape, Key>::CopyKeysTo(
FixedArray* storage, FixedArray* storage,
int index,
typename Dictionary<Shape, Key>::SortMode sort_mode) { typename Dictionary<Shape, Key>::SortMode sort_mode) {
ASSERT(storage->length() >= NumberOfElementsFilterAttributes( ASSERT(storage->length() >= NumberOfElementsFilterAttributes(
static_cast<PropertyAttributes>(NONE))); static_cast<PropertyAttributes>(NONE)));
int capacity = HashTable<Shape, Key>::Capacity(); int capacity = HashTable<Shape, Key>::Capacity();
int index = 0;
for (int i = 0; i < capacity; i++) { for (int i = 0; i < capacity; i++) {
Object* k = HashTable<Shape, Key>::KeyAt(i); Object* k = HashTable<Shape, Key>::KeyAt(i);
if (HashTable<Shape, Key>::IsKey(k)) { if (HashTable<Shape, Key>::IsKey(k)) {
......
...@@ -2810,7 +2810,7 @@ class Dictionary: public HashTable<Shape, Key> { ...@@ -2810,7 +2810,7 @@ class Dictionary: public HashTable<Shape, Key> {
PropertyAttributes filter, PropertyAttributes filter,
SortMode sort_mode); SortMode sort_mode);
// Fill in details for properties into storage. // Fill in details for properties into storage.
void CopyKeysTo(FixedArray* storage, SortMode sort_mode); void CopyKeysTo(FixedArray* storage, int index, SortMode sort_mode);
// Accessors for next enumeration index. // Accessors for next enumeration index.
void SetNextEnumerationIndex(int index) { void SetNextEnumerationIndex(int index) {
......
...@@ -4584,9 +4584,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { ...@@ -4584,9 +4584,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) {
// Get the property names. // Get the property names.
jsproto = obj; jsproto = obj;
int proto_with_hidden_properties = 0; int proto_with_hidden_properties = 0;
int next_copy_index = 0;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
jsproto->GetLocalPropertyNames(*names, jsproto->GetLocalPropertyNames(*names, next_copy_index);
i == 0 ? 0 : local_property_count[i - 1]); next_copy_index += local_property_count[i];
if (jsproto->HasHiddenProperties()) { if (jsproto->HasHiddenProperties()) {
proto_with_hidden_properties++; proto_with_hidden_properties++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment