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

Unified Diff: sky/engine/tonic/dart_wrappable.cc

Issue 934863002: ParentNode#appendChild(null) shouldn't crash (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: git cl format Created 5 years, 10 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
Index: sky/engine/tonic/dart_wrappable.cc
diff --git a/sky/engine/tonic/dart_wrappable.cc b/sky/engine/tonic/dart_wrappable.cc
index 1bf69d4cf5b023ba6101340539b1f5c3b40edcde..a7ab0d2f9bc52331593a8266fc47882a19569087 100644
--- a/sky/engine/tonic/dart_wrappable.cc
+++ b/sky/engine/tonic/dart_wrappable.cc
@@ -7,8 +7,10 @@
#include "sky/engine/tonic/dart_class_library.h"
#include "sky/engine/tonic/dart_error.h"
+#include "sky/engine/tonic/dart_exception_factory.h"
#include "sky/engine/tonic/dart_state.h"
#include "sky/engine/tonic/dart_wrapper_info.h"
+#include "sky/engine/wtf/text/StringBuilder.h"
namespace blink {
@@ -74,9 +76,17 @@ DartWrappable* DartConverterWrappable::FromArguments(Dart_NativeArguments args,
DartWrappable* DartConverterWrappable::FromArgumentsWithNullCheck(
Dart_NativeArguments args, int index, Dart_Handle& exception) {
- Dart_Handle handle = Dart_GetNativeArgument(args, index);
- if (Dart_IsNull(handle))
+ Dart_Handle handle = Dart_GetNativeArgument(args, index);
+ if (Dart_IsNull(handle)) {
+ DartState* state = DartState::Current();
+ StringBuilder message;
+ message.appendLiteral("Argument ");
+ message.appendNumber(index);
+ message.appendLiteral(" cannot be null.");
+ exception = state->exception_factory().CreateException("ArgumentError",
+ message.toString());
return nullptr;
+ }
intptr_t native_fields[DartWrappable::kNumberOfNativeFields];
Dart_Handle result = Dart_GetNativeFieldsOfArgument(
args, index, DartWrappable::kNumberOfNativeFields, native_fields);

Powered by Google App Engine
This is Rietveld 408576698