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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 10584044: Check that the C string passed to Dart_NewString is valid UTF-8. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 2478437c5c4a0c6bf724bcbf38dca39e4362ce96..f21fee6ca8a8c46da107127e57dfe6ed5151922a 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1499,6 +1499,14 @@ DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* len) {
DART_EXPORT Dart_Handle Dart_NewString(const char* str) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
+ if (str == NULL) {
+ return Api::NewError("%s expects argument 'str' to be non-null.",
hausner 2012/06/20 22:05:25 You can use the macro CHECK_NOT_NULL() for this.
cshapiro 2012/06/20 22:09:06 This turns out to be part of the debugger API. I
+ CURRENT_FUNC);
+ }
+ if (!Utf8::IsValid(str)) {
+ return Api::NewError("%s expects argument 'str' to be valid UTF-8.",
+ CURRENT_FUNC);
+ }
return Api::NewHandle(isolate, String::New(str));
}
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698