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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 12089071: IO v2: Handle illegal arguments to socket writes (Closed) Base URL: http://dart.googlecode.com/svn/experimental/lib_v2_io/dart/
Patch Set: Created 7 years, 11 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: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 17848)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -2030,7 +2030,6 @@
}
-// TODO(hpayer): value should always be smaller then 0xff. Add error handling.
#define GET_LIST_ELEMENT_AS_BYTES(isolate, type, obj, native_array, offset, \
length) \
const type& array = type::Cast(obj); \
@@ -2039,8 +2038,15 @@
for (int i = 0; i < length; i++) { \
element = array.At(offset + i); \
if (!element.IsInteger()) { \
- return Api::NewError("%s expects the argument 'list' to be " \
- "a List of int", CURRENT_FUNC); \
+ Dart_Handle argument_error_class = \
+ Dart_GetClass( \
+ Dart_LookupLibrary(Dart_NewStringFromCString("dart:core")), \
+ Dart_NewStringFromCString("ArgumentError")); \
+ Dart_Handle args[1]; \
+ args[0] = Dart_NewStringFromCString("List contains non-int elements"); \
+ Dart_Handle exception = \
+ Dart_New(argument_error_class, Dart_Null(), 1, args); \
+ return Dart_ThrowException(exception); \
} \
const Integer& integer = Integer::Cast(element); \
native_array[i] = static_cast<uint8_t>(integer.AsInt64Value() & 0xff); \

Powered by Google App Engine
This is Rietveld 408576698