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)); |
} |