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

Side by Side Diff: src/elements.cc

Issue 9808110: Check double array bounds in HasElementImpl. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-119925.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 if (key < static_cast<uint32_t>(length)) { 837 if (key < static_cast<uint32_t>(length)) {
838 FixedDoubleArray::cast(obj->elements())->set_the_hole(key); 838 FixedDoubleArray::cast(obj->elements())->set_the_hole(key);
839 } 839 }
840 return obj->GetHeap()->true_value(); 840 return obj->GetHeap()->true_value();
841 } 841 }
842 842
843 static bool HasElementImpl(Object* receiver, 843 static bool HasElementImpl(Object* receiver,
844 JSObject* holder, 844 JSObject* holder,
845 uint32_t key, 845 uint32_t key,
846 FixedDoubleArray* backing_store) { 846 FixedDoubleArray* backing_store) {
847 return !backing_store->is_the_hole(key); 847 return key < static_cast<uint32_t>(backing_store->length()) &&
848 !backing_store->is_the_hole(key);
848 } 849 }
849 }; 850 };
850 851
851 852
852 // Super class for all external element arrays. 853 // Super class for all external element arrays.
853 template<typename ExternalElementsAccessorSubclass, 854 template<typename ExternalElementsAccessorSubclass,
854 ElementsKind Kind> 855 ElementsKind Kind>
855 class ExternalElementsAccessor 856 class ExternalElementsAccessor
856 : public ElementsAccessorBase<ExternalElementsAccessorSubclass, 857 : public ElementsAccessorBase<ExternalElementsAccessorSubclass,
857 ElementsKindTraits<Kind> > { 858 ElementsKindTraits<Kind> > {
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 1413 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
1413 new_backing_store->set(0, length); 1414 new_backing_store->set(0, length);
1414 { MaybeObject* result = array->SetContent(new_backing_store); 1415 { MaybeObject* result = array->SetContent(new_backing_store);
1415 if (result->IsFailure()) return result; 1416 if (result->IsFailure()) return result;
1416 } 1417 }
1417 return array; 1418 return array;
1418 } 1419 }
1419 1420
1420 1421
1421 } } // namespace v8::internal 1422 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-119925.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698