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

Side by Side Diff: runtime/vm/dart_api_message.cc

Issue 2278763002: Handle empty string messages in Dart_PostCObject (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | runtime/vm/snapshot_test.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/dart_api_message.h" 5 #include "vm/dart_api_message.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/snapshot_ids.h" 7 #include "vm/snapshot_ids.h"
8 #include "vm/symbols.h" 8 #include "vm/symbols.h"
9 #include "vm/unicode.h" 9 #include "vm/unicode.h"
10 10
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 WriteDouble(object->value.as_double); 1179 WriteDouble(object->value.as_double);
1180 break; 1180 break;
1181 case Dart_CObject_kString: { 1181 case Dart_CObject_kString: {
1182 const uint8_t* utf8_str = 1182 const uint8_t* utf8_str =
1183 reinterpret_cast<const uint8_t*>(object->value.as_string); 1183 reinterpret_cast<const uint8_t*>(object->value.as_string);
1184 intptr_t utf8_len = strlen(object->value.as_string); 1184 intptr_t utf8_len = strlen(object->value.as_string);
1185 if (!Utf8::IsValid(utf8_str, utf8_len)) { 1185 if (!Utf8::IsValid(utf8_str, utf8_len)) {
1186 return false; 1186 return false;
1187 } 1187 }
1188 1188
1189 Utf8::Type type; 1189 Utf8::Type type = Utf8::kLatin1;
1190 intptr_t len = Utf8::CodeUnitCount(utf8_str, utf8_len, &type); 1190 intptr_t len = Utf8::CodeUnitCount(utf8_str, utf8_len, &type);
1191 ASSERT(len > 0);
1192 if (len > String::kMaxElements) { 1191 if (len > String::kMaxElements) {
1193 return false; 1192 return false;
1194 } 1193 }
1195 1194
1196 // Write out the serialization header value for this object. 1195 // Write out the serialization header value for this object.
1197 WriteInlinedHeader(object); 1196 WriteInlinedHeader(object);
1198 // Write out the class and tags information. 1197 // Write out the class and tags information.
1199 WriteIndexedObject(type == Utf8::kLatin1 ? kOneByteStringCid 1198 WriteIndexedObject(type == Utf8::kLatin1 ? kOneByteStringCid
1200 : kTwoByteStringCid); 1199 : kTwoByteStringCid);
1201 WriteTags(0); 1200 WriteTags(0);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 if (!success) { 1331 if (!success) {
1333 UnmarkAllCObjects(object); 1332 UnmarkAllCObjects(object);
1334 return false; 1333 return false;
1335 } 1334 }
1336 } 1335 }
1337 UnmarkAllCObjects(object); 1336 UnmarkAllCObjects(object);
1338 return true; 1337 return true;
1339 } 1338 }
1340 1339
1341 } // namespace dart 1340 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698