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

Unified Diff: src/objects.cc

Issue 8509003: Limit length of strings copied into a heap snapshot (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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/profile-generator.h » ('j') | src/profile-generator.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index e20893615ccc398af8a2cb5ce53ed9a83e4ef313..44ca9e70e150909098b43eb8bf9cbb26bcdac833 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5826,11 +5826,9 @@ SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls,
buffer->Reset(offset, this);
int character_position = offset;
int utf8_bytes = 0;
- while (buffer->has_more()) {
+ while (buffer->has_more() && character_position < offset + length) {
uint16_t character = buffer->GetNext();
- if (character_position < offset + length) {
- utf8_bytes += unibrow::Utf8::Length(character);
- }
+ utf8_bytes += unibrow::Utf8::Length(character);
character_position++;
mnaganov (inactive) 2011/11/09 11:45:23 This can be moved up into the loop clause.
}
@@ -5845,15 +5843,13 @@ SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls,
buffer->Seek(offset);
character_position = offset;
int utf8_byte_position = 0;
- while (buffer->has_more()) {
+ while (buffer->has_more() && character_position < offset + length) {
uint16_t character = buffer->GetNext();
- if (character_position < offset + length) {
- if (allow_nulls == DISALLOW_NULLS && character == 0) {
- character = ' ';
- }
- utf8_byte_position +=
- unibrow::Utf8::Encode(result + utf8_byte_position, character);
+ if (allow_nulls == DISALLOW_NULLS && character == 0) {
+ character = ' ';
}
+ utf8_byte_position +=
+ unibrow::Utf8::Encode(result + utf8_byte_position, character);
character_position++;
mnaganov (inactive) 2011/11/09 11:45:23 Same here.
}
result[utf8_byte_position] = 0;
« no previous file with comments | « no previous file | src/profile-generator.h » ('j') | src/profile-generator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698