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

Unified Diff: src/heap.cc

Issue 196133030: Make max size and max length of strings consistent. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/heap-inl.h » ('j') | src/hydrogen.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 6790fe9847c6fa52baf5c170fd27cbb149cc5f31..e2b83f507a999a4103c23b9f26ddb7c615383a0c 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -4972,16 +4972,13 @@ MaybeObject* Heap::AllocateInternalizedStringImpl(
int size;
Map* map;
+ if (chars > String::kMaxLength) {
+ return Failure::OutOfMemoryException(0x9);
+ }
if (is_one_byte) {
- if (chars > SeqOneByteString::kMaxLength) {
- return Failure::OutOfMemoryException(0x9);
- }
map = ascii_internalized_string_map();
size = SeqOneByteString::SizeFor(chars);
} else {
- if (chars > SeqTwoByteString::kMaxLength) {
- return Failure::OutOfMemoryException(0xa);
- }
map = internalized_string_map();
size = SeqTwoByteString::SizeFor(chars);
}
@@ -5023,7 +5020,7 @@ MaybeObject* Heap::AllocateInternalizedStringImpl<false>(
MaybeObject* Heap::AllocateRawOneByteString(int length,
PretenureFlag pretenure) {
- if (length < 0 || length > SeqOneByteString::kMaxLength) {
+ if (length < 0 || length > String::kMaxLength) {
return Failure::OutOfMemoryException(0xb);
}
int size = SeqOneByteString::SizeFor(length);
@@ -5047,7 +5044,7 @@ MaybeObject* Heap::AllocateRawOneByteString(int length,
MaybeObject* Heap::AllocateRawTwoByteString(int length,
PretenureFlag pretenure) {
- if (length < 0 || length > SeqTwoByteString::kMaxLength) {
+ if (length < 0 || length > String::kMaxLength) {
return Failure::OutOfMemoryException(0xc);
}
int size = SeqTwoByteString::SizeFor(length);
« no previous file with comments | « no previous file | src/heap-inl.h » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698